Doctrine orm 连接2会导致错误
我试图在Doctrine orm 连接2会导致错误,doctrine-orm,dql,doctrine-query,Doctrine Orm,Dql,Doctrine Query,我试图在DQL中加入两个查询,但我得到一个错误,它说 [Semantical Error]第0行,第114列靠近“(选择u.email)”:错误:类“(”未定义。 我已经经历过了。但是我想不出来。请帮忙。 我的质询如下: $filterQuery = "SELECT tempResult1.email as email,tempResult1.name as name , tempResult1.id as user FROM (select
DQL
中加入两个查询,但我得到一个错误,它说
[Semantical Error]第0行,第114列靠近“(选择u.email)”:错误:类“(”未定义。
我已经经历过了。但是我想不出来。请帮忙。
我的质询如下:
$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();
您混合了两个Doctrine2概念:
- 使用SQL
- 使用DQL
EntityManager::createNativeQuery()
方法并将SQL查询设置为参数
EntityManager::createQuery()
仅用于DQL查询您混合了Doctrine2的两个概念:
- 使用SQL
- 使用DQL
EntityManager::createNativeQuery()
方法并将SQL查询设置为参数
EntityManager::createQuery()
仅用于DQL查询