[FLOW3-general] Avoid "double" table joins in the query

Maurizio Monticelli rugbymauri at gmail.cm
Wed Feb 6 00:12:35 CET 2013


Hi All

i try to make a query with associated tables. but i don't get the 
desired results. Because the query joins the assoicated table two times.

The "m3_" table should not be joined and 'm3_.state' should on the m2_ 
table. See below.

Any hints?
I'm still using FLOW3 1.1


Model:

class Player {

      ....

     /**
      * The attendances
      * @var 
\Doctrine\Common\Collections\ArrayCollection<\MOM\PlayerProfile\Domain\Model\Trainingattendance>
      * @ORM\OneToMany(mappedBy="player")
      */
     protected $attendances;

     .....
}


PHP:
         $query->matching(
             $query->logicalAnd(
                 ...
                 $query->equals('attendances.training', $training),
                 $query->equals('attendances.state', '')
             )
	}



SQL:

SELECT ... FROM
     ...
     mom_playerprofile_domain_model_trainingattendance m2_
         ON m1_.flow3_persistence_identifier = m2_.player LEFT JOIN
     mom_playerprofile_domain_model_trainingattendance m3_
         ON m1_.flow3_persistence_identifier = m3_.player
WHERE
     ...
     m2_.training = '36533425-1f2c-4ca0-af15-e5087d629841'  AND
     m3_.state = ''


More information about the FLOW3-general mailing list