Doctrine2: applying a filter to an association

For example, if I have:

class Parent {

/* ... */

/** One to Many association */
protected $children;

}

class Child
{
/* .. */
/** many to one association */
protected $parent;

/* name of child column */
protected $name;
}

Now, say, for a parent, I want to filter the children by their name. If possible, somehow making parent.getChildren () with this filter would be nice, but it's not possible.

I would like it to probably have the syntax getChildrenByName (), but this function seems unsuitable for the ORM class and the repository class. Anyone have any suggestions?

+5
source share
1 answer

This function allows you to add criteria when extracting associations:

Work with associations: collection filtering

+9
source