[TYPO3-mvc] Howto check if an object exists in a objectstorage
Franz Koch
typo3.RemoveForMessage at elements-net.de
Thu Jul 8 12:13:06 CEST 2010
On 08.07.2010 11:15, Alex Bailey wrote:
> Thanks Franz This really got me a big step forward :),
> If I look if 2 objects exist in the storage my repository returns all
> objects which has either 1 or the other object, thats still not perfect
> but I think its the right way (is there something I have to mind when I
> use the In method on the query if I want the query to match all of the
> values and not just 1?
$query->in won't help in this case, so you have to build up the
constraints by yourself and concatenate them, like you would with
regular SQL. So think about how you would build up the SQL statement in
raw SQL and rebuild that. Something like that maybe, but I haven't
really thought about how to query for this the best way.
$workfieldConstraints = array();
foreach ($this->filter->getWorkfields() as $workfield) {
$workfieldConstraints[] = $query->equals('workfield.uid',$workfield);
}
return $query->matching(
$query->logicalAnd(
$someOtherConstraints,
$query->logicalAnd($workfieldConstraints)
)
)->execute();
--
kind regards,
Franz Koch
More information about the TYPO3-project-typo3v4mvc
mailing list