1
我在搜索现有日期时遇到了一些问题。查找日期Laravel 5.2
在型号:
$date = '2016-01-14';
public static function getByDate($date)
{
$query = self::select('date', DB::raw('SUM(test_count) as test'))
->whereDate('date', '=', $date)
->groupBy('date')
->orderBy('date', 'ASC')
->get();
}
但我没有得到一个结果,因为这个代码创建SQL:
select `date`, SUM(test_count) as test from `test_table` where date(`date`) = 2016-01-14 group by `date` order by `date` asc limit 1
各地日期=> 2016年1月14日
未报价如何解决它?
我尝试使用参数whereRaw使用,例如:
return $query->whereRaw("date= ?",[$date]);
,但它并没有帮助...