3 回答
![?](http://img1.sycdn.imooc.com/533e4bec0001ae5302000200-100-100.jpg)
TA贡献1856条经验 获得超5个赞
简短答案
在config\database.php-> "mysql"数组中
设置'strict' => false为全部禁用。
.... 要么
您可以离开'strict' => true模式并"mysql"在其中添加选项
'mysql' => [
...
....
'strict' => true,
'modes' => [
//'ONLY_FULL_GROUP_BY', // Disable this to allow grouping by one column
'STRICT_TRANS_TABLES',
'NO_ZERO_IN_DATE',
'NO_ZERO_DATE',
'ERROR_FOR_DIVISION_BY_ZERO',
'NO_AUTO_CREATE_USER',
'NO_ENGINE_SUBSTITUTION'
],
]
详细答案
您可能不需要禁用所有严格的选项。有关此问题,请查看此答案。
![?](http://img1.sycdn.imooc.com/5333a0350001692e02200220-100-100.jpg)
TA贡献1786条经验 获得超13个赞
这可能是一个SQL_MODE问题。在您的中config/database.php,在连接中,更改
strict => false
如
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
![?](http://img1.sycdn.imooc.com/533e4c0500010c7602000200-100-100.jpg)
TA贡献1844条经验 获得超8个赞
每当雄辩地使用groupBy时,请始终在select()函数中包括在groupBy函数中使用的列名。
$loadids=explode("#@*",$reciptdet->loading_id);
$loadingdatas=DB::table('loading')->select('vehicle_no')->groupBy('vehicle_no')->whereIn('id',$loadids)->get();//add select('vehicle_no')
在配置文件中禁用严格模式也是一种不好的做法。这样做可能会导致损坏的数据进入数据库,例如无效的日期而没有任何警告,除非绝对必要,否则请勿这样做。
- 3 回答
- 0 关注
- 545 浏览
添加回答
举报