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]
How to fix it please ?
Wouldnât it be possible to automatically update the queries in the ORM core?
After all, that works perfectly disabling this *ÂŁ$#£¤ option, so it could be possible to generate a âdefaultâ GROUP BY assertion no?
SELECT TcategoriesSitecategories.tcategory_id AS `Sitecategories_CJoin__tcategory_id`,
TcategoriesSitecategories.sitecategory_id AS `Sitecategories_CJoin__sitecategory_id`,
TcategoriesSitecategories.id AS `Sitecategories_CJoin__id`,
Sitecategories.id AS `Sitecategories__id`,
Sitecategories.code AS `Sitecategories__code`,
Sitecategories.field_id AS `Sitecategories__field_id`,
Sitecategories.created AS `Sitecategories__created`,
Sitecategories.modified AS `Sitecategories__modified`,
Sitecategories.icon_name AS `Sitecategories__icon_name`,
Sitecategories.name_fr AS `Sitecategories__name_fr`,
FROM sitecategories Sitecategories
INNER JOIN tcategories_sitecategories TcategoriesSitecategories
ON Sitecategories.id = (TcategoriesSitecategories.sitecategory_id)
WHERE TcategoriesSitecategories.tourinsoftcategory_id in (:c0)
GROUP BY Sitecategories.id
Obviously, looking at the MySQL query, I guess I have to add TcategoriesSitecategories.id in GROUP BY clause, but I donât see how to do it in CakePHP code.
Also, except to wait for the error to occur, itâs not easy to guess to add this group() clause in the query.
Ok but the problem here concerns the join table. I donât talk about it in my query, CakePhp automatically creates this intermediate query so I donât see how I can specify the group() statement.
You use group when you want to do a function or a special process on fields that you wannaâŚ
example:
$this->User->find(âallâ,
âfieldsâ => array(âCOUNT(âUser.salaryâ) as sum_salaryâ),
âgroupâ => array(âUser.salaryâ)
);