[Flow] Repository question regarding joins

David Sporer david.sporer at gmail.com
Wed Mar 4 13:29:27 CET 2015


I found out that the query works in general that if I execute the DQL like
this:

$query = $this->entityManager->createQuery($queryBuilder->getQuery()->getDQL());
$query->setParameters(array(
	'customer' => $customer
        'searchString' => '%'.$searchString.'%'
));

Anyway it doesn't really feel 'right' to do it this way...
I also had to build my own Pagination Widget that supports arrays but this
is the easier part.

Regards
David

2015-03-03 22:02 GMT+01:00 David Sporer <david.sporer at gmail.com>:

> 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
> _______________________________________________
> Flow mailing list
> Flow at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow


More information about the Flow mailing list