What I'm trying to do is a query that basically says "for a given
(individual#1), return all other (individuals) that are referenced by
(groups) where each (group) fits the following criteria:
• (individual#1) does NOT belong to the (group)
• the (group) belongs to a (school) that references a (group) that refers
to (individual#1)
I am not having luck with trying to do this using this ODM.
I thought I'd start simple and just try to do the initial part of this
problem:
For a given (individual) object, return all the (schools) that reference
(groups) that reference the (individual). Since "school" owns the
relationship with "group" which owns the relationship with "individual",
this seemed like it would be the natural way to do this.
First I tried:
public function rebatesValidWith(Documents\Individual $individual) {
$qb = $this->dm->createQueryBuilder('Documents\School')
->field('groups.individuals')->includesReferenceTo(
$individual);
$query = $qb->getQuery();
$schools = $query->execute();
return $schools;
}
That doesn't work. It just says, "no mapping found for field
'groups.individuals'. However I'm quite sure that the Documents\Group class
has a field called "individuals".
What is the point of a relational system that only goes one level deep?
I see that there is an issue related to this:
https://github.com/doctrine/mongodb-odm/issues/624
So what is a workaround for this?
I was able to successfully prime 'groups' and 'individuals' in the same
query by making a custom primer as suggested by Nikolai Zujev in a comment
on issue 624 (see the above link), but I'm not sure what good priming does
me in this case, since I still get the same error, even when I do that:
public function rebatesValidWith(Documents\Individual $individual) {
$qb = $this->dm->createQueryBuilder('Documents\School')
->field('groups')->prime($myCustomPrimer)
->addAnd($qb->expr()->
field('groups.individuals')->includesReferenceTo(
$individual)
);
$query = $qb->getQuery();
$schools = $query->execute();
return $schools;
}
That also fails.
Suggestions?
--
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 http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.