私はsymfonyに正しく参加しようとしています。ここDoctrine 2 - Outer join queryと here Symfony - Using Outer Joins with Doctrine ORM で説明されているように試しました。
$query = $em->getRepository('AppBundle:raports')->createQueryBuilder('r')
->select('r')
->leftJoin('r.requestRaports rr WITH rr.formId = :formId', false)
->setParameter('formId', $requestId->getFormId())
->getQuery();
それは与えます
SELECT
r0_.id AS id_0,
r0_.adminComment AS adminComment_1,
r0_.addDate AS addDate_2,
r0_.submitDate AS submitDate_3,
r0_.statusId AS statusId_4,
r0_.userId AS userId_5,
r0_.requestId AS requestId_6,
r0_.requestRaports AS requestRaports_7
FROM
raports r0_
LEFT JOIN request_raports r1_ ON r0_.requestRaports = r1_.id
AND (r1_.formId = ?)
私がしようとすると
$query = $em->getRepository('AppBundle:raports')->createQueryBuilder('r')
->select('r')
->join('r.requestRaports rr WITH rr.formId = :formId', false)
->setParameter('formId', $requestId->getFormId())
->getQuery();
そのように見える
SELECT
r0_.id AS id_0,
r0_.adminComment AS adminComment_1,
r0_.addDate AS addDate_2,
r0_.submitDate AS submitDate_3,
r0_.statusId AS statusId_4,
r0_.userId AS userId_5,
r0_.requestId AS requestId_6,
r0_.requestRaports AS requestRaports_7
FROM
raports r0_
INNER JOIN request_raports r1_ ON r0_.requestRaports = r1_.id
AND (r1_.formId = ?)
しかし、私は次のようなクエリが必要です
SELECT * FROM
raports
r RIGHT JOIN request_raports rr ON r.requestRaports
= rr.id
doctrine2で正しい結合を機能させるには?