Reputation: 7935
I'm totally off the balance now, since I spend couple of hours googling and found nothing solid. I want to do a leftJoin
in Symfony2 (using Doctrine). From the docs, I'm here:
$ownRepo = $this->getDoctrine()
->getRepository('GameShelfUsersBundle:Ownership');
$ownQuery = $ownRepo->createQueryBuilder('own')
->where('own.user = :user')
->andWhere('own.own = :type')
->setParameters(array(
'user' => $user,
'type' => $type
))
->orderBy('own.updated','desc')
->getQuery();
$own = $ownQuery->getResult();
Now, for God's sake, how do I do leftJoin
? I tried adding
->leftJoin('GameShelfGamesBundle:Games','g')
with various additions (ON own.game = g.id
etc) but it doesn't work at all. Any help? I'm still a novice in this ;(
Upvotes: 1
Views: 71
Reputation: 13189
Symfony2 is using Doctrine2 as a ORM, so looking this topic up in the doctrine documentation is a good idea. From the docs:
leftJoin('own.games', 'g')
This only works if the property in your Ownership class is called games
!
Upvotes: 3