Php ORM for mysql now()-Laravel 4
我有以下sqlPhp 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_
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()”)。