使用reviews
选项时如何获得一组独特的结果(例如matching
)?
如果没有多个review
,那么我得到的是没有区别的呼叫,我得到的是同一comments
的多个。通过不重复的调用,我得到以下错误。
Syntax error or access violation SELECT list is not in GROUP BY clause and contains nonaggregated column Comments.id which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
$this->Products->find()
->contain(['Reviews' => function($q) {
return $q->distinct(['Reviews.id'])->matching(['Comments', function($q) {
return $q->where(['Comments.created >=' => new DateTime('-10days')]);
}
}
我将如何构建查询来检索与Reviews
上的某些条件匹配的不同Comments
?