I already encountered such problem but I don't understand how to define group()
in this case:
I have the following tables:
Articles {
'id',
'name',
}
Categories {
'id',
'name'
}
ArticlesCategories {
'article_id',
'category_id'
}
And the query is:
$seconds = $this->Categories->find()
->contain([
'Articles' => function ($q) {
return $q->distinct(['Articles.id']);
}
])
->where([
'Categories.name IN' => $themeNames,
->all();
The error is:
Exception: SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'base.ArticlesCategories.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by in [/var/www/mySite/vendor/cakephp/cakephp/src/Database/Statement/MysqlStatement.php, line 36]
So as the problems seems to come from the join table, I don't see how to write the group()
clause.