gpt4 book ai didi

mysql - Eloquent : "WHERE (equals statement) AND (LIKE statement)"

转载 作者:行者123 更新时间:2023-11-29 02:50:12 28 4
gpt4 key购买 nike

我基本上想做的是:

select * from request where id = 1 and created_at like (today's date);

但使用 Eloquent 。

我试过:

 $query = m_requests::where(['id' => Auth::User()->id, "created_at", "like", "%".date("Y-m-d")."%"]);

但这会返回错误:

SQLSTATE[42S22]: Column not found: 1054 Unknown
column '0' in 'where clause' (SQL: select * from
from `request` where (`id` = 1 and `0` = created_at
and `1` = like and `2` = %2016-04-22%))

有谁知道我怎样才能实现我想要做的事情?

总结:我希望 id 等于请求的 id,但我希望日期是“LIKE”今天的日期(这是因为我只对创建日期而不是创建时间感兴趣)。

干杯

最佳答案

试试这个,它应该工作:

m_requests::where('id', '=', Auth::user()->id)
->where('created_at', 'LIKE', '%'.date("Y-m-d").'%');

关于mysql - Eloquent : "WHERE (equals statement) AND (LIKE statement)",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36793986/

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