Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php ORM for mysql now()-Laravel 4_Php_Mysql_Laravel_Laravel 4_Eloquent - Fatal编程技术网

Php ORM for mysql now()-Laravel 4

Php ORM for mysql now()-Laravel 4,php,mysql,laravel,laravel-4,eloquent,Php,Mysql,Laravel,Laravel 4,Eloquent,我有以下sql select * from bids where deleted_at is null and publication_date <= now() and open_date >= now() select*from bids,其中deleted_at为空 和出版物_date=now() 我想用ORM写它 $bids = Bid::where('publication_date','<=','now()')->where('open_

我有以下sql

select * from bids where deleted_at is  null 
and  publication_date <= now() and open_date >= now()   
select*from bids,其中deleted_at为空
和出版物_date=now()
我想用ORM写它

   $bids = Bid::where('publication_date','<=','now()')->where('open_date','>=','now()')->get();
$bids=Bid::where('publication_date','=','now()')->get();
它不工作,然后我重写如下

$bids=DB::select(DB::raw('select * from bids where deleted_at is  null and  publication_date <= now() and open_date >= now()'));
$bids=DB::select(DB::raw('select*from bids,其中deleted_at为null,publication_date=now());
如何在ORM上编写上述查询, 我认为
now()
是出了问题

您可以使用:

$bids=Bid::whereRaw('publication_date=now()')->get()

如果不想在整个查询中完全使用原始数据,也可以在where语句中使用DB::raw(“NOW()”)。