[TYPO3-mvc] Extbase Query with n:m relation

Aimo Künkel mail at aimo.cc
Thu Jul 25 14:00:39 CEST 2013


Hi all,

first post in the mailing list, so let's get it on:

 

I have a bidirectional n:m relation user <> group, which works fine.

Now I need a query in the userrepository that returns all the users in a given set of groups.

 

So something like this (note that $groups is an objectstorage and the 'groups' property also is)

 

public function findByGroups ( $groups ) {

                $query = $this->createQuery();

>>>        $groupConstraint = $query->XYZ('groups', $objectGroups);

                $query->matching( $groupConstraint );

                return $query->execute();

}

 

This is how I think it should work, if I knew what the marked line should look like exactly.

If I understand 'in' and 'contains' correctly, they're not what I need.

 

I also think about making a loop over $groups and creating an 'in' constraint for every group and OR'ing them all up, but I'm not an sql guru so maybe that's really slow and unnecessary.

 

The real situation is far more complex, but that nails it down to where I stuck atm.

 

Kind Regards and thanks in advance,

Aimo Künkel



More information about the TYPO3-project-typo3v4mvc mailing list