Association Mapping in Doctrine 2
<?php class User { //... /** * @ManyToMany(targetEntity="Group") * @JoinTable(name="User_Group", * joinColumns={@JoinColumn(name="User_id", referencedColumnName="id")}, * inverseJoinColumns={@JoinColumn(name="Group_id", referencedColumnName="id")} * ) */ private $groups; //... }
In the test, assuming in this example $ groups, initialized as ArrayCollection () in the constructor, returns all groups associated with the user.
The programmer in my development team raised a good point in this scenario. It loads all the groups associated with the user entity, we may not need all of them.
When executing DQL join operators, we can say that we want to select favorite groups that are reachable using DQL joins, we join the user, group and favorites. Does Doctrine repeat all groups? This is the overhead that I am trying to indicate, an array of all groups has already been collected there.
How do we control the result of association comparisons? Or, if we remove association mappings, can we still use DQL to merge objects that do not have association mappings configuration? OR, does Doctrine really use data from association mappings in DQL?
source share