CakePHP 2.x Containable 内的 GROUP BY

2024-03-22

我正在疯狂地尝试找到一个好的解决方案,要么使用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);

我不想通过破解来解决这个问题 - 有没有更简单的方法来做到这一点?


对于通过谷歌偶然发现这一点的其他人来说,看起来好像GROUP BY可包含查询的条件Cake 1 或 2 不支持 https://github.com/cakephp/cakephp/issues/1759,因此如果必须分组,则需要手动加入。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

CakePHP 2.x Containable 内的 GROUP BY 的相关文章

随机推荐