[TYPO3-mvc] extbase query - contains() and in()

Christian Essl essl at incert.at
Fri Jan 20 12:00:49 CET 2012

I have a model with a field named "tags" which contains an array of values.
Now I want to find all objects by a list of tags, but there is a problem with the provided in() and contains()-methods.

contains() searches a property-array for ONE value.
In() searches a property for an ARRAY of values.

But what I want is to search a property-array for an ARRAY of values. (where only one of the searched values would have to be true)
Arrays on both sides. But how do I accomplish that?
I could not find any functions for this purpose.

For example, this wouldn't work because contains() excepts a plain value for the operand:

  public function findByTags($tags)
   // $tags = '1,2,3,4'
    $tags = explode(',', $tags);
    $query = $this->createQuery();
      $query->contains('tags', $tags)
    return $query->execute();
But my approach would be very similar to contains(). I only need to find all objects which have at least _one_ of the tags from $tags.


More information about the TYPO3-project-typo3v4mvc mailing list