Discussion:
[TYPO3-english] extbase, custom queries and intersection
Éric Thibault
2017-10-27 14:00:27 UTC
Permalink
Thank you Mikel for your suggestions but they unfortunately dont work in our situation…

Both the « contains » and « in » work the same… they retrieve all events having at least one of the wished categories, doing an OR search. What we need for our projet is an AND search… retrieve only events having all the categories selected!

Is there a way to achive that or is it impossable with the « constraints » method and we should use the « statement » method?

A million thanks to all!


Eric Thibault
Mikel
2017-10-27 15:47:46 UTC
Permalink
Try something like that:

$query = $this->createQuery();
$constraints = [];

foreach (explode(',', $categories) as $categoryUid) {
$constraints[] = $query->contains('categories', $categoryUid);
}


$query->matching($query->logicalAnd($constraints));

Loading...