【问题标题】:SELECT statement in a LEFT JOIN statement with DOCTRINE in SYMFONY?在 SYMFONY 中使用 DOCTRINE 的 LEFT JOIN 语句中的 SELECT 语句?
【发布时间】:2011-03-08 07:51:35
【问题描述】:

有没有什么方法可以使用 symfony 在 Doctrine 中运行这个 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

object(sfOutputEscaperIteratorDecorator)#560

使用您的代码?我认为那是因为 HYDRATE MODE,但我不太清楚。

【问题讨论】:

    标签: join symfony1 doctrine


    【解决方案1】:

    您可以尝试像这样执行原始 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);
    

    【讨论】:

      猜你喜欢
      • 2010-09-27
      • 2012-10-09
      • 2022-08-15
      • 2018-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-02
      • 2014-10-18
      相关资源
      最近更新 更多