有没有办法在Doctrine中使用symfony运行这个SQL查询?
$q = "SELECT a.id as app_id, b.title as gameTitle FROM application a
LEFT JOIN application_translation b on a.id=b.id
LEFT OUTER JOIN (SELECT m.application_id as m_id, count(m.member_id) as total
FROM member_application m GROUP BY m.application_id) x on x.m_id = a.id
WHERE a.is_active=1 AND a.is_mobile = 1
ORDER BY x.total DESC";
更新
感谢您的回复。只有一件事,我怎么能转换
对象(sfOutputEscaperArrayDecorator)#524
到
对象(sfOutputEscaperIteratorDecorator)#560
使用你的代码?我认为这是因为水合模式,但我不明白。
答案 0 :(得分:2)
您可以尝试执行原始SQL:
$q = "SELECT a.id as app_id, b.title as gameTitle FROM application a
LEFT JOIN application_translation b on a.id=b.id
LEFT OUTER JOIN (SELECT m.application_id as m_id, count(m.member_id) as total
FROM member_application m GROUP BY m.application_id) x on x.m_id = a.id
WHERE a.is_active=1 AND a.is_mobile = 1
ORDER BY x.total DESC";
$doctrine = Doctrine_Manager::getInstance()->getCurrentConnection()->getDbh();
$result = $doctrine->query($q);