Sorry, there was a typo that didn't help.
It's a fundamental/simple question, so apologies if you were hoping it was
more interesting/technical.
I think I'm confused at the interplay between bidirectionality in the
database entities, vs. keeping collections in-sync in memory (like
'assignedToBug and 'addReportedBug' in your tutorial), vs.
persistence-triggering writes (must be on the owning side).
Maybe my concrete example will be clear.
In my case, each Employee has many Role Assignments. Each Role Assignment
points to one Employee and one Role. So each Role has many Role
Assignments.
I'm using an association class (Role Assignments). I think this is just
controlling the join table between a ManyToMany relationship.
My understanding is that Doctrine2 will persist and hydrate everything just
fine.
But when it comes to keeping objects sync'd *in memory*, I've got to do
that with userland functions ('assignedToBug' and 'addReportedBug' in the
tutorial).
Do I need to though? I want to find out a current employee's current,
active roles.
Rather than worry about sync'ing and traversing the objects with:
$currentRoleAssignments = $employee->getCurrentRoleAssignments();
foreach ($currentRoleAssignments as $roleAssignment) {
if ($roleAssignment->isActive()) {
$roles[] = $roleAssignment->getRole();
}
}
Why not just a single, DQL query?
Something like:
SELECT ra, r, p FROM RoleAssignment ra JOIN ra.person p JOIN ra.role r
WITH p.id = :pid AND ra.active = true;
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.