How to disable only_full_group_by option in Laravel
In Laravel, you could do this on runtime instead of making a global setting
//disable ONLY_FULL_GROUP_BY
DB::statement("SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));");
//Your SQL goes here - The one throwing the error (:
//re-enable ONLY_FULL_GROUP_BY
DB::statement("SET sql_mode=(SELECT CONCAT(@@sql_mode, ',ONLY_FULL_GROUP_BY'));");
Add this modes to config/database.php
'mysql' => [
...
'modes' => [
'STRICT_ALL_TABLES',
],
],
If you set
'strict' => true
. Some sql exception will not throw like sql data integrity exception.
To answer the original question, if you want to disable this in Laravel you have to change the 'strict' value to false in your database configuration in config/database.php.
'connections' => [
...
'mysql' => [
...
'strict' => false,
...
],
]