Let’s say I have 3 tables related.
Groups -> (HAS_MANY) Labels -> (HAS_MANY) attributes
To get the groups with their labels I would use:
Is there a way to retrieve all records (groups+labels+attributes)?
(tri - Tommy Riboe)
Have you tried this? Assuming an ‘attribs’ relationship declaration in Label.
Groups::model()->with ('labels', 'labels.attribs')->findAll()
For a complete list of the whole set you will need a nested foreach.
An alternative is to start the query from Attribs.
Attribs->(BELONGS_TO)Labels->(BELONGS_TO)Groups, that is.
Thanks Tommy, that did it.
In that case it’s also sufficient to write: