本文介绍了分组不起作用-Laravel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法在Laravel 5.3中运行此简单查询
I'm not able to run this simple query in Laravel 5.3
$top_performers = DB::table('pom_votes')
->groupBy('performer_id')
->get();
它给了我
SQLSTATE[42000]: Syntax error or access violation: 1055 'assessment_system.pom_votes.id' isn't in GROUP BY (SQL: select * from `pom_votes` group by `performer_id`)
但是,如果我从错误中复制原始查询并直接在PhpMyAdmin中启动,则可以正常工作.
However if I copy raw query from the error and fire directly in PhpMyAdmin, it works fine.
我已经检查过了:
https://laravel.com/docs/5.3/querys#ordering-grouping-limit-and-offset
将寻求任何帮助.
谢谢
Parth Vora
Parth Vora
推荐答案
编辑应用程序的数据库配置文件config/database.php
Edit your applications's database config file config/database.php
在mysql
数组中,设置strict => false
以禁用MySQL的严格模式
In mysql
array, set strict => false
to disable MySQL's strict mode
这篇关于分组不起作用-Laravel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!