CakePHP 2.x GROUP BY内部包含

num*_*l25 3 php lamp cakephp cakephp-2.x

我很努力地尝试使用set::extract()或之类的东西找到一个好的解决方案。我想在我的容器中添加一个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);
Run Code Online (Sandbox Code Playgroud)

我不想破解这个问题-有更简单的方法吗?

Dom*_*bbs 5

对于通过Google偶然发现此问题的其他任何人,似乎Cake 1或2不支持可包含GROUP BY查询的条件,因此如果必须分组,则需要手动联接。