Doctrine Subquery in InnerJoin

谁说胖子不能爱 提交于 2019-12-05 01:35:34

i tried to execute my custom query directly by Doctrine Row Sql query option and its work :) i loved to share it here :

$q = new Doctrine_RawSql();
        $q->select('{t.won}, {e.etot}, {s.username},{s.country},{r.marks},{r.ranks}');
        $q->from('sf_Guard_User s INNER JOIN marks r ON r.user_id = s.id inner join (select t.id,t.user_id,count(t.user_id)as won from topper t group by t.user_id) t on t.user_id=s.id inner join (select d.id,d.user_id,count(e.user_id)as etot from exams e group by e.user_id) e on e.user_id=s.id ORDER BY r.rank asc');
        $q->addComponent('s', 'sfGuardUser s');
        $q->addComponent('r', 's.Marks r');
        $q->addComponent('t', 's.Topper t');
        $q->addComponent('e', 's.Exams e');
        return $q;

for more help read it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!