gpt4 book ai didi

php - ORM for mysql now() - Laravel 4

转载 作者:可可西里 更新时间:2023-11-01 07:58:50 25 4
gpt4 key购买 nike

我有下面的sql

select * from bids where deleted_at is  null 
and publication_date <= now() and open_date >= now()

我想用ORM写

   $bids = Bid::where('publication_date','<=','now()')->where('open_date','>=','now()')->get();

它不起作用,然后我重写如下

$bids=DB::select(DB::raw('select * from bids where deleted_at is  null and  publication_date <= now() and open_date >= now()'));

如何在 ORM 上编写上述查询,我认为 now() 有问题

最佳答案

您可以使用 whereRaw method :

$bids = Bid::whereRaw('publication_date <= now() and open_date >= now()')->get();

关于php - ORM for mysql now() - Laravel 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25116240/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com