Éric Thibault
2017-10-26 20:23:47 UTC
Hello to all!
I need some help in using the query API inside my extbase plugin. Here is my situation:
1. We have 3 tables, events, categories an events-categories (intersection table n-m relation)
2. We can filter the events by categories via flexform field
When we shoose multilple categories to filter, our constraint is relatively straightforward, retrieving all events that have at least one of the categories:
$uidlist = explode(',', $settings['categories']);
$constraints[] = $query->in('categorie.uid', $uidlist);//matches all events with a least one category in the list
It's fine if we want an OR but what can we use if we want all categories that have all our chosen categories? If we want an AND?
We've tried a foreach loop :
$uidlist = explode(',', $settings['categories']);
foreach($uidlist AS $categorie) {
$constraintsAND[] = $query->equals('categorie.uid', intval($categorie));//match all events with a specific category
}
$constraints[] = $query->logicalAnd($constraintsAND);
But no events are returned even if our test event has all the categories selected!
I'm lost here so if someone can shed a little light I would be eternaly gratefull!
Thank you a million times!
Eric Thibault
I need some help in using the query API inside my extbase plugin. Here is my situation:
1. We have 3 tables, events, categories an events-categories (intersection table n-m relation)
2. We can filter the events by categories via flexform field
When we shoose multilple categories to filter, our constraint is relatively straightforward, retrieving all events that have at least one of the categories:
$uidlist = explode(',', $settings['categories']);
$constraints[] = $query->in('categorie.uid', $uidlist);//matches all events with a least one category in the list
It's fine if we want an OR but what can we use if we want all categories that have all our chosen categories? If we want an AND?
We've tried a foreach loop :
$uidlist = explode(',', $settings['categories']);
foreach($uidlist AS $categorie) {
$constraintsAND[] = $query->equals('categorie.uid', intval($categorie));//match all events with a specific category
}
$constraints[] = $query->logicalAnd($constraintsAND);
But no events are returned even if our test event has all the categories selected!
I'm lost here so if someone can shed a little light I would be eternaly gratefull!
Thank you a million times!
Eric Thibault