【发布时间】:2016-09-17 14:28:20
【问题描述】:
我正在尝试在 DQL 中加入 2 个查询,但我收到一条错误消息,提示:
[Semantical Error] line 0, col 114 near '(select u.email': Error: Class '(' is not defined.
我已经通过 https://stackoverflow.com/questions/24600439/error-in-nested-subquery-in-dql-class-is-not-defined。但我想不通。请帮忙。
我的查询如下:
$filterQuery = "SELECT tempResult1.email as email,tempResult1.name as name , tempResult1.id as user
FROM (select u.email as email,a.name as name , u.id as user
FROM
Application\Entity\Userhasrole uhr
INNER JOIN
Application\Entity\Oauthrole r with uhr.applicationrole = r.id
INNER JOIN
Application\Entity\Application a with r.application = a.id
INNER JOIN
Application\Entity\Oauthusers u
) tempResult1
LEFT JOIN
(SELECT uhr1.user as user FROM Application\Entity\Userhasrole uhr1 where
a.id = :applicationId
) tempResult2
with tempResult1.user = tempResult2.user";
$queryObject = $this->getEntityManager()
->createQuery($filterQuery);
$queryObject->setParameter('applicationId', $applicationId);
$result = $queryObject->getResult();
【问题讨论】:
标签: doctrine-orm dql doctrine-query