CakePHP 2.x GROUP BY内部包含 [英] CakePHP 2.x GROUP BY within Containable

查看:106
本文介绍了CakePHP 2.x GROUP BY内部包含的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论是使用set::extract()还是类似的东西,我都在努力寻找一个好的解决方案.我想在我的容器中添加一个GROUP BY:

I am going nuts trying to find a good solution, either using the set::extract() or something. I want to add a GROUP BY within my containable:

$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);

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

I do not want to hack to get around this issue - is there an easier way to do this?

推荐答案

对于通过Google偶然发现此问题的其他人来说,可容纳查询的条件似乎是GROUP BY

For anyone else that stumbles on this via Google, it looks as though GROUP BY conditions for containable queries aren't supported in Cake 1 or 2, so a manual join would be required if grouping is a must.

这篇关于CakePHP 2.x GROUP BY内部包含的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆