Skip to content

Instantly share code, notes, and snippets.

@hissy
Last active December 16, 2021 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hissy/8ef404aa7292f5ef95eb814a8d500111 to your computer and use it in GitHub Desktop.
Save hissy/8ef404aa7292f5ef95eb814a8d500111 to your computer and use it in GitHub Desktop.
#concrete5 set sql_mode from database.php config file
<?php
/**
* How to set sql_mode from database.php
* It will help to solve the error like "SQLSTATE[42000]: Syntax error or access violation:
* 1055 Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column
* 'concrete5.cv.cvPublishDate' which is not functionally dependent on columns in GROUP BY clause;
* this is incompatible with sql_mode=only_full_group_by"
*/
return [
'default-connection' => 'concrete',
'connections' => [
'concrete' => [
'driver' => 'c5_pdo_mysql',
'server' => '127.0.0.1',
'database' => 'concrete5',
'username' => 'username',
'password' => 'password',
'character_set' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'driverOptions' => [
PDO::MYSQL_ATTR_INIT_COMMAND => "SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''))",
],
],
],
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment