使用匹配时检索不同的行

时间:2019-06-06 00:49:09

标签: cakephp orm cakephp-3.7

使用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

0 个答案:

没有答案