【问题标题】:Yii disambiguate columns with three level "with" in relational queryYii 在关系查询中用三级“with”消除列的歧义
【发布时间】:2012-05-14 06:20:13
【问题描述】:

以下情况:

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

消除“cmets”歧义的解决方案是:

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

但是如果我有三个层次呢:

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

???如何同时消除 cmets 和 author 的歧义?

提前致谢

【问题讨论】:

    标签: php activerecord orm yii relational-database


    【解决方案1】:

    试试这个

    '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'))))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-09
      • 1970-01-01
      相关资源
      最近更新 更多