我知道也有人问过类似的问题,但他们都没有适合我的解决方案.
我有一个名为Events的表,它有一个标题为"EVENT_FINISH_TIME"的列,一个时间戳.我需要获得在某个时间戳(通常是now()->format(...)
)之后结束的所有事件.我编写了以下代码作为测试:
$timestamp = "2020-11-22 13:00:00";
$events = Events::where('event_finish_time', '>=', '"'.$timestamp.'"');
dd($events->get("*")->toArray());
This code returns []
.
Using toSql()
and getBindings()
, I get:
select * from `events` where `event_finish_time` >= ?
and "2020-11-22 13:00:00"
The combination (select * from `events` where `event_finish_time` >= "2020-11-22 13:00:00"
) runs perfectly fine from phpMyAdmin, and returns the correct result.
Setting the binding to 'TIMESTAMP("' . now() . '")'
doesn't help with the php query and does not affect the direct SQL one.
What could be the cause of this issue? I have checked the spelling of all the tables and columns.