Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save afurculita/17cafd95c40e912dd75788c67c166b1d to your computer and use it in GitHub Desktop.
Save afurculita/17cafd95c40e912dd75788c67c166b1d to your computer and use it in GitHub Desktop.
Doctrine 2 - Beware of lazy loading when querying entities with associations
<?php
//$em is the entity manager
$qb = $em->createQueryBuilder();
$qb
->select('Article', 'Comment')
->from('Entity\Article', 'Article')
->leftJoin('Article.comment', 'Comment')
;
$query = $qb->getQuery();
return $query->getResult();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment