[TYPO3-mvc] Extbase query IN / contains m:n Relation

Mark mmarquis at digipets.de
Fri Oct 26 17:22:05 CEST 2012


Hello,

I have a query with a m:n relation (products - category).
In my query I have an Array of category IDs. I want to get all Products which are at least in one of the Arrays categories.
I tried using in($propertyName, $operand), but it seems that this method doesn't support the m:n relation (or am I wrong here?).

I have found a possibility using contains with each category in the array an wrapping an logicalOr around.
$query->logicalOr($query->contains('category', 2),$query->contains('category', 5) , ... );
something like that.
But now I have the Problem that I don´t know how to write the query dynamically when I don´t know how big my category  array is (depends on how many checkboxes are checked in the frontend).
How can I automatically fill the parenthesis in the logicalOr with an unknown number ob contains queries with a loop or otherwise?

Has somebody an idea??

Thanks and best regards

Mark





More information about the TYPO3-project-typo3v4mvc mailing list