ubuntu16.04 apache2.4 php7.0 mysql5.7php
$order_goods=db('order_goods')->where('orderid','in',$_orderid_arr)->group('orderid')->having('id>0')->select(); echo db('order_goods')->getLastSql();exit;
輸出結果mysql
ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'orderid' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_bysql
解決辦法apache
1.查看sql_model參數ubuntu
mysql -u root -p
SELECT @@GLOBAL.sql_mode;
看到bash
ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION php7
而後 this
set sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
刷新spa
flush privileges;
退出mysqlrest
exit;
編輯mysql配置文件
vi /etc/mysql/mysql.conf.d/mysql.cnf
加入這一行
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
重啓mysql
service mysql restart
完成。
注:service mysql reload 無用。