Skip to content

Instantly share code, notes, and snippets.

@cakper
Created December 8, 2011 07:29
Show Gist options
  • Save cakper/1446386 to your computer and use it in GitHub Desktop.
Save cakper/1446386 to your computer and use it in GitHub Desktop.
Doctrine not working eager loading
<?php
$query = $em->createQuery('SELECT t FROM JazzyTransactionBundle:MoneyTransaction t WHERE t.sender = :user')->setParameter('user', $user);
$query->setFetchMode("JazzyTransactionBundle:MoneyTransaction", "sender", "EAGER");
$transactions = $query->execute();
WORKING:
<?php
$query = $em->createQuery('SELECT t FROM JazzyTransactionBundle:MoneyTransaction t WHERE t.sender = :user')->setParameter('user', $user);
$query->setFetchMode("Jazzy\TransactionBundle\Entity\MoneyTransaction", "sender", \Doctrine\ORM\Mapping\ClassMetadata::FETCH_EAGER);
$transactions = $query->execute();
@kafoso
Copy link

kafoso commented Apr 18, 2018

@vetalt: Thank you, Sir! This trolled me for a littel while.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment