I’ve had a search around the approx 3,596,443 posts and tutorials about many to many relationships but can’t seem to find anything that resolves my problem. The easiest way to explain it is, I think, the same way I’m using it. I have a parent -> child relation of (theoretically infinete) between 2 - 5 levels deep. It’s a simple many_many back to the same table using a link table between them.
group -> group_link(parent_id, child_id) -> group
Everything works fine. Provided I use the lazy loading approach, so I can step through in a foreach as many times as I like. But if I want to speed up performance somewhat and use the ‘with’ parameter it all goes to hell. This is because the alias on the many to many is hard coded in the foreign key definition of the relation:
'children'=>array(self::MANY_MANY, 'Group', 'group_link(parent, child)', 'on'=>'children_children.type="G"', 'order'=>'children_children.order'),
It still persists if I remove the ‘on’ and ‘order’ params, but they show it’s how linked and that I do need to reference the table alias in the relation to add conditions and the order.