In this case the EntityManager simply acts as a central point to get Query
objects from. So yes, in a way, it is a shortcut.
The point is that the snippet of code you present should be contained by a
method in a Repository:
class BugRepository extends EntityRepository
{
public function findASpecialCase()
{
$dql = "SELECT b, e, r FROM Bug b JOIN b.engineer e JOIN b.reporter
r ORDER BY b.created DESC";
$query = $this->getEntityManager()->createQuery($dql);
$query->setMaxResults(30);
return $query->getResult();
}
}
--
Jasper N. Brouwer
(@jaspernbrouwer)
On 21 October 2014 at 09:46:43, Mathieu Decaffmeyer ([email protected]) wrote:
> > Looking up data is not a responsibility of the EntityManager: it's a
> > repository concern.
>
> In the example bug tracker demo from the docs, the Entity Manager is used
> for finding and displaying the list of bugs :
>
> $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->setMaxResults(30);$bugs
> = $query->getResult();
>
> Is createQuery a shortcut too? As you should normally use a repository to
> look up for data as you said.
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.