带有时间戳条件的查询在php中工作但在laravel原始查询中不起作用

时间:2017-11-14 13:45:06

标签: php mysql laravel-5.3

我在PHP中运行了以下查询,效果很好。

SELECT * FROM transactions LEFT JOIN actions ON transactions.id_transaction_id = actions.id_transaction_id where transactions.server_datetime_trans >= '2017-11-07 12:00:00' AND transactions.server_datetime_trans <='2017-11-07 12:59:59' 

但我尝试在laravel中运行相同的查询。它不起作用,始终显示empty array()

尝试了两种类型的Laravel代码:

TYPE 1 ::

$data=DB::select(DB::raw("SELECT * FROM transactions LEFT JOIN actions ON transactions.id_transaction_id = actions.id_transaction_id where transactions.server_datetime_trans >= '2017-11-07 12:00:00' AND transactions.server_datetime_trans <='2017-11-07 12:59:59'"));
print_r($data);

TYPE 2 ::

$data=DB::select("SELECT * FROM transactions LEFT JOIN actions ON transactions.id_transaction_id = actions.id_transaction_id where transactions.server_datetime_trans >= '2017-11-07 12:00:00' AND transactions.server_datetime_trans <='2017-11-07 12:59:59'");
print_r($data);

两者都显示empty array()作为结果

0 个答案:

没有答案