[TYPO3-mvc] Howto check if an object exists in a objectstorage

Franz Koch typo3.RemoveForMessage at elements-net.de
Thu Jul 8 10:40:01 CEST 2010


Hey Alex,

> thanks for your answer but this doesn't seem to fix my problem, maybe
> its something else? Do I have to build the query by using foreach:
>
> Example: foreach ($filter->getWorkfields() as $workfield)
> $constraints[] = $query->contains('workfield', $workfield);
>
> or is it also possible to pass an array with objects to the query? Since
> I get an exception if I do it maybe I'm doing something wrong <:
>
> Example: $query->contains('workfield', $filter->getWorkfields());

Ah, ok, now I think I got you. Is the the property 'workfield' of the 
object you're quering for of type RELATION_HAS_ONE (so only refers to 
one workfield)?  If so, try this:

// this is working for me
$query->equals('workfield', $filter->getWorkfields());

// if the workfield property is n_n, try this:
$query->in('workfield.uid', $filter->getWorkfields());

-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list