moriesta
moriesta

Reputation: 1200

Yii disambiguate columns with three level "with" in relational query

In the following case:

'with'=>array('pros.comments', 'cons.comments')

the solution of disambiguating 'comments' is:

'with'=>array('pros.comments', 'cons.comments'=>array('alias'=>'con_comments'))

But what if I have three levels:

'with'=>array('pros.comments.author', 'cons.comments.author')

??? How to disambiguate both comments and author?

Thanks in advance

Upvotes: 1

Views: 267

Answers (1)

dInGd0nG
dInGd0nG

Reputation: 4114

Try this

'with'=array('pros.comments'=>array('alias'=>'pros_comments','with'=>array('author'=>array('alias'=>'pros_comments_author'))),'cons.comments'=>array('alias'=>'cons_comments','with'=>array('author'=>array('alias'=>'cons_comments_author'))))

Upvotes: 1

Related Questions