通过Laravel分组? [英] Group by Laravel?

查看:40
本文介绍了通过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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆