[Flow] Repository question regarding joins
David Sporer
david.sporer at gmail.com
Tue Mar 3 22:02:11 CET 2015
Hi,
I have a model called PassInstance that has a Collection of PushNotificationRegistrations attached to it.
Now I want to create a repository function that returns all PassInstances that have a PushNotificationRegistration with status 1 attached.
In SQL I’d use a join for this so I thought I’d try this in Flow also.
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->resetDQLParts()->select('p')->from(‚\My\Project\Domain\Model\PassInstance', 'p')
->join('p.pushNotificationRegistrations', 'n')
->join('p.pass', 'pass')
->where("n.status=:status")
->andWhere("p.searchString LIKE :searchString")
->andWhere("pass.customer = :customer")
->setParameters(
array('status'=>1,
'searchString' => '%'.$searchString.'%',
'customer' => $customer));
return $query->execute();
Unfortunately this returns all of my PassInstances.
If I print the dql query generated by the queryBuilder ($queryBuilder->getQuery()->getDQL()) and replace the parameters manually it is working when I’m executing it with ./flow doctrine:dql
This is the query generated: SELECT p FROM \My\Project\Domain\Model\PassInstance p INNER JOIN p.pushNotificationRegistrations n INNER JOIN p.pass pass WHERE n.status=:status AND p.searchString LIKE :searchString AND pass.customer = :customer
Can you help me? :-)
Regards,
David
More information about the Flow
mailing list