This works in constructions including ‘with’ call. I.e. Step::model()->with(‘prevStep’)->findAll();
But when I try to get prevStep as a property, the query is generated without JOIN clause. And, of course, MySQL cannot find the table with alias t while executing the query.
I’ve found a solution but it’s wrong because it includes the table as a through:
In this case the problem is solved, but there are two issues:
Another join to the same table.
Example includes only one realtion, in my code i have 10 of them and i need to create such proxy join for every relation.
So the question is: is there any other way to get what I’ve done? If there’s not maybe some option could be added to relation that defines forced join?
If you use the relations in both ways create 2 relations, it looks odd but in the case of $model->prev you have to check $this->step instead of set an on condition.
Not an elegant solution IMHO. I’d prefer to write different queries for lazy load and find with related models for a single relation. The substance should have only one name in every possible cases. And of course when i write the code i wouldn’t like to think about which exactly name of the currently used substance i should use.
So I’d propose to add options for lazy loaded variation of relation that could be substituted with the original ones when not specified.