I want to retrive a collection of object as result of cities grouped by name, my query is
public function getDistinctCitiesName()
{
$qb = $this->createQueryBuilder("cc");
->add('groupBy', 'cc.name');
return $qb;
}
When run i have an exception
request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\DriverException: "An exception occurred while executing 'SELECT c0_.id AS id_0, c0_.name AS name_1, c0_.postal_code AS postal_code_2, c0_.country AS country_3, c0_.state AS state_4, c0_.visible AS visible_5 FROM cities c0_ GROUP BY c0_.name': SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'www.c0_.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by"
I can't disable the only_full_group_by mode, so is there a solution ?