$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 );
内嵌查询可以通过:
$sql = '';
$result = Yii::app()->db->createCommand($sql)->query();
内嵌查询可以通过:
$sql = '';
$result = Yii::app()->db->createCommand($sql)->query();
还是使用 createCommand() 比较简单。