I installed the new Ubuntu and my code has got a problem with MySQL.
( ! ) Warning: PDOStatement::execute(): SQLSTAT
To get ->distinct('some_column')
to work for me, I needed to disable ONLY_FULL_GROUP_BY
option in mysql modes.
Rather than edit the mysql config file on the filesystem, I followed the instructions at Laravel : Syntax error or access violation: 1055 Error and added this to config/database.php
:
'strict' => true,
'modes' => [
// 'ONLY_FULL_GROUP_BY', // disabled 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'
],
In my project, the modes
property was non-existent, so I simply pasted that bad boy in there.
NOTE: Make sure you understand that wiping the modes entirely is undesirable, and basically not strict mode, so you will lose debugging warning/error messages about stuff like varchar length exceeded. The trick is to avoid
sql_mode=""
. Notice how above I am using 6 modes and explicitly omittingONLY_FULL_GROUP_BY
.