当前位置:Gxlcms > PHP教程 > yii中使用ar可以进行嵌套吗?

yii中使用ar可以进行嵌套吗?

时间:2021-07-01 10:21:17 帮助过:6人阅读

$c             = new CDbCriteria();$c->join   = "left join (select goods_id, group_concat(name) as `tags` from goods_tag group by goods_id) `tag` on tag.goods_id=t.id";$res = Goods::model()->with( 'brand' )->findAll( $c );

类似上面的查询(上面的不对,查不出 tags字段),yii用ar可以查询吗?具体怎么操作?


回复讨论(解决方案)

relation里面有写规则不? 先看下CActiveRecord源码 实在不行直接用sql吧

还是使用 createCommand() 比较简单。

人气教程排行