laravel操作數據庫的時候有時候會發(fā)現如下錯誤:
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即可