laravel 报错this is incompatible with sql_mode=only_full_group_by

laravel操作数据库的时候有时候会发现如下错误:

SQLSTATE[42000]: Syntax error or access violation: 
1055 Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'vuespa.messages.user_id' which is not functionally dependent on columns in GROUP BY clause;
this is incompatible with sql_mode=only_full_group_by (SQL: select type,user_id,see,count(*) as count from `messages` group by `type` having `see` = 0 and `user_id` = 1)

这是因为laravel mysql数据库开启了严格模式,导致很多mysql语句可能会报错,我们可以将其关闭即可

找到config/database.php,修改'strict' => true,改为false即可


©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容