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

Sebastian Schreiber me at schreibersebastian.de
Thu Jul 25 16:05:34 CEST 2013


Hello Aimo,
you have given yourself all the answers ;-)

Try to loop over $groups

$orConstraints = array();
foreach($groups as $group) {
     $orConstraints[] = $query->contains('group', $group);
}
if(is_array($orConstraints) && !empty($orConstraints)) {
$query->matching($query->logicalOr($orConstraints));
return $query->execute

Am 25.07.2013 14:00, schrieb Aimo Künkel:
> 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
>
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc


-- 
Sebastian Schreiber
(Medieninformatiker B.Sc.)
(TYPO3 Certified Integrator)

Schanzenstraße 27, Schlosserei 4
D-51063 Köln

T  0221 677 88 541
M  0176 431 05 790

Skype schreibersebastian.de

me at schreibersebastian.de
www.schreibersebastian.de

Steuernummer: 219 / 5302 / 3123



More information about the TYPO3-project-typo3v4mvc mailing list