1
0
mirror of synced 2024-12-14 07:06:04 +03:00

fix entity manager reference in repository code sample

This commit is contained in:
Gordon Franke 2011-03-31 14:57:27 +08:00 committed by Benjamin Eberlei
parent abc8f29800
commit 63c431f01d

View File

@ -1202,7 +1202,7 @@ the previoiusly discussed query functionality in it:
{
$dql = "SELECT b, e, r FROM Bug b JOIN b.engineer e JOIN b.reporter r ORDER BY b.created DESC";
$query = $entityManager->createQuery($dql);
$query = $this->getEntityManager()->createQuery($dql);
$query->setMaxResults($number);
return $query->getResult();
}
@ -1211,7 +1211,7 @@ the previoiusly discussed query functionality in it:
{
$dql = "SELECT b, e, r, p FROM Bug b JOIN b.engineer e ".
"JOIN b.reporter r JOIN b.products p ORDER BY b.created DESC";
$query = $em->createQuery($dql);
$query = $this->getEntityManager()->createQuery($dql);
$query->setMaxResults($number);
return $query->getArrayResult();
}
@ -1221,7 +1221,7 @@ the previoiusly discussed query functionality in it:
$dql = "SELECT b, e, r FROM Bug b JOIN b.engineer e JOIN b.reporter r ".
"WHERE b.status = 'OPEN' AND e.id = ?1 OR r.id = ?1 ORDER BY b.created DESC";
return $entityManager->createQuery($dql)
return $this->getEntityManager()->createQuery($dql)
->setParameter(1, $userId)
->setMaxResults($number)
->getResult();
@ -1231,11 +1231,11 @@ the previoiusly discussed query functionality in it:
{
$dql = "SELECT p.id, p.name, count(b.id) AS openBugs FROM Bug b ".
"JOIN b.products p WHERE b.status = 'OPEN' GROUP BY p.id";
return $em->createQuery($dql)->getScalarResult();
return $this->getEntityManager()->createQuery($dql)->getScalarResult();
}
}
To be able to use this query logic through ``$entityManager->getRepository('Bug')``
To be able to use this query logic through ``$this->getEntityManager()->getRepository('Bug')``
we have to adjust the metadata slightly.
.. configuration-block::