我正在努力寻找一个好的解决方案,要么使用 set::extract()
之类的。我想在我的 containable 中添加一个 GROUP BY:
$params = array(
'conditions'=>array(
'Project.id'=>$ProjectId
),
'contain'=>array(
//Gets the User Who owns the Project
'User'=>$user,
'Bid'=>array(
//The User Who owns the Bid
'User'=>$user
),
'ProjectType',
'Os',
'Comment'=>array(
'To'=>$user,
'From'=>$user,
'group'=>"Comment.from_id"
),
),
);
//debug($params);
return $this->find('first',$params);
我不想通过破解来解决这个问题 - 有更简单的方法吗?
最佳答案
对于通过 Google 偶然发现此问题的任何其他人,它看起来好像是可包含查询的 GROUP BY
条件 aren't supported in Cake 1 or 2 ,因此如果必须进行分组,则需要手动加入。
关于php - CakePHP 2.x 在 Containable 中使用 GROUP BY,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7970873/