通过Laravel分组? [英] Group by Laravel?
本文介绍了通过Laravel分组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下查询:
$orders = Order::where(function ($query) use ($request) {
// Filter by in process delivery
if ($request->get("status") && $request->get("status") == "2") {
$query->where('status', "2");
}
})->groupBy('created_at')->get();
当我尝试执行此查询时,出现错误:
When I try to execute this query I get an error:
SQLSTATE[42000]: Syntax error or access violation: 1055 'delivery.order.id' isn't in GROUP BY (SQL: select * from `order` group by `created_at`)
出什么问题了?
推荐答案
在您的config/database.php
文件中,更改mysql
配置数组
In your config/database.php
file, change mysql
configuration array
来自'strict' => true
到'strict' => false
For more information about this error read this answer.
这篇关于通过Laravel分组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文