[Flow] Query on OneToMany relation
Alexander Götz
goetz.al at gmail.com
Tue Apr 29 11:46:31 CEST 2014
Thank you for your replies.
Just in case that anyone has similar problems here is my solution:
*/***
* * **@Flow\Inject*
** **@var **\TYPO3\Flow\Persistence\Doctrine\Service*
* */*
protected $doctrineService;
$result = $this->doctrineService->runDql("SELECT c FROM My\Example\Domain\M
odel\CalendarEntry c JOIN c.attendees a WHERE (a.member = '".$this->
persistenceManager->getIdentifierByObject($member)."' AND a.status != 7)
ORDER BY c.start ASC");
2014-04-26 20:22 GMT+02:00 Christian Müller <christian.mueller at typo3.org>:
> Sorry Philipp but notice that attendees is a collection and he wants to
> compare to a property of the collection members... That IMHO won't work. ;)
>
> Cheers,
> Christian
>
>
> Zedd wrote:
>
>> Uhm,
>>
>> this should work out of the box (sorry Christian :D). The issue here
>> seems to be the orderings.
>>
>> This is wrong (actually, it's sorting by 'start', then by 'ASC'):
>> ->setOrderings(array(
>> ’start', \TYPO3\Flow\Persistence\QueryInterface::ORDER_ASCENDING
>> ))
>>
>> Try this instead (notice that the property is the key, the direction the
>> value):
>> ->setOrderings(array(
>> ’start' => \TYPO3\Flow\Persistence\QueryInterface::ORDER_ASCENDING
>> ))
>>
>> Additionally, you might want to consider using the models identifier
>> instead of passing the object directly to QueryObject::equals. While it
>> doesn't break for "equals", it might when using "in" or "contains".
>>
>> Greetings,
>> Philipp Maier
>>
>> On Apr 26, 2014, at 7:53 PM, Christian Müller<christian.mueller at typo3.org>
>> wrote:
>>
>> Hi Alexander,
>>>
>>> $query = $this->createQuery();
>>>> $result = $query->matching(
>>>> $query->logicalAnd(
>>>> $query->equals('attendees.member', $member),
>>>> Is it even possible without using SQL syntax?
>>>>
>>>
>>> No, for this type of question you need to use a DQL query because you
>>> need to join the attendees and then query for member...
>>> Cheers,
>>> Christian
>>> _______________________________________________
>>> Flow mailing list
>>> Flow at lists.typo3.org
>>> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
>>>
>>
>> _______________________________________________
> Flow mailing list
> Flow at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
>
More information about the Flow
mailing list