WhereBetween函数在Laravel 5.0中无法正常工作

时间:2017-08-21 11:52:08

标签: laravel-5

$dt = \Carbon::now();
$tomorrow = Carbon::tomorrow();
$yesterday = Carbon::yesterday();
$data = $this->model->select('id', 'description')
 ->whereBetween($dt, array($yesterday, $tomorrow))->get();

它返回错误“数据库操作中发生错误。

1 个答案:

答案 0 :(得分:0)

wherebetween子句中,第一个参数应该是表列字段,您要对其进行比较。 例如:

$data = $this->model->select('id', 'description')
 ->whereBetween('created_date', array($yesterday, $tomorrow))->get();