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

WBOY
Release: 2016-06-23 13:47:45
Original
900 people have browsed it

$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 );
Copy after login


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


回复讨论(解决方案)

内嵌查询可以通过:
$sql = '';
$result = Yii::app()->db->createCommand($sql)->query();

内嵌查询可以通过:
$sql = '';
$result = Yii::app()->db->createCommand($sql)->query();



你用的是 ado 查询是吧,我想问问 ar 有没有办法可以实现。。

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

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template