[TYPO3-mvc] Extbase query with AND over 1:n related objects
g4-lisz at tonarchiv.ch
g4-lisz at tonarchiv.ch
Thu Mar 29 13:10:26 CEST 2012
Hi there.
Is there a way to do a query like this:
Object from class A (e.g. "book") has a property which is related 1:n to
class B (e.g. "category"). One book can belong to more than one categories.
Now i like to do a query which finds all books with category B=1 AND B=2
i.e. the book has to belong to both categories.
If i do something like this:
if (count($demand->getCategories()) > 0) {
foreach ($demand->getCategories() as $category)
$constraints[] =
$query->equals('book.category.uid', $category);
}
$query->matching($query->logicalAnd($constraints));
then i get all books which belong to one of the categories (same like "
$constraints[] = $query->in('book.category.uid',
$demand->getCategories());")
Any help would be much appreciated!
Cheers,
Till
More information about the TYPO3-project-typo3v4mvc
mailing list