fix entity manager reference in repository code sample
This commit is contained in:
parent
abc8f29800
commit
63c431f01d
@ -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";
|
$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);
|
$query->setMaxResults($number);
|
||||||
return $query->getResult();
|
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 ".
|
$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";
|
"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);
|
$query->setMaxResults($number);
|
||||||
return $query->getArrayResult();
|
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 ".
|
$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";
|
"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)
|
->setParameter(1, $userId)
|
||||||
->setMaxResults($number)
|
->setMaxResults($number)
|
||||||
->getResult();
|
->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 ".
|
$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";
|
"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.
|
we have to adjust the metadata slightly.
|
||||||
|
|
||||||
.. configuration-block::
|
.. configuration-block::
|
||||||
|
Loading…
Reference in New Issue
Block a user