Symfony 1.4原则查询addSelect

时间:2019-10-14 14:12:11

标签: php doctrine symfony-1.4

最近我将Symfony项目1.2升级到1.4,但是在我的Doctrine查询中出现错误。

这是我在Apache error.log中遇到的错误

SQLSTATE[42P01]: Undefined table: 7 ERROR:  falta una entrada para la tabla \xc2\xabi4\xc2\xbb en la cl\xc3\xa1usula FROM\nLINE 1: ... doctrine_subquery_alias.id FROM (SELECT DISTINCT i4.id FROM...\n                                                             ^

这是我在Model目录中的主义查询

        $q = $this->createQuery('r')
        ->select('r.*')
        ->addSelect("(SELECT CONCAT(p.nombres, ' ', p.apellido_paterno, ' ', apellido_materno) FROM MulPersona p LEFT JOIN p.InvBien b1 WHERE b1.id = r.id AND p.estado = true LIMIT 1) fun_baja")
        ->leftJoin('r.InvGrupo ig')
        ->where('r.estado = ?', true)
        ->andWhere('r.resolucion_baja is not null')
        ->orderBy(sprintf('ig.codigo %s', $orden))
        ->addOrderBy(sprintf('r.correlativo %s', $orden));
        return $q->execute();

问题出在addSelect命令中,但我无法解决

请帮助,非常感谢!

[更新] 当打印SQL代码时,我得到以下信息:

SELECT i.*, 

(SELECT m.apellido_materno AS m__0, m.nombres || ' ' || m.apellido_paterno || ' ' || m.apellido_materno AS m__0 
FROM mul_persona M 
LEFT JOIN inv_bien i3 ON m.id = i3.mul_persona_baja_id 

WHERE m.id IN
    (SELECT doctrine_subquery_alias.id 
     FROM (SELECT DISTINCT i4.id 
             FROM mul_persona m2 
             LEFT JOIN inv_bien i6 ON m2.id = i6.mul_persona_baja_id 
             WHERE (i6.id = i4.id AND m2.estado = true) 
             LIMIT 1
             ) AS doctrine_subquery_alias
    )

    AND (i3.id = i.id AND m.estado = TRUE)
) AS i__0 

FROM inv_bien i 
LEFT JOIN inv_grupo i2 ON i.inv_grupo_id = i2.id 
WHERE (i.estado = true AND i.resolucion_baja is not NULL) 
ORDER BY i2.codigo ASC, i.correlativo ASC 

别名i4不存在!

0 个答案:

没有答案