Can I use ar in yii for nesting?

Source: Internet
Author: User
Can I use ar in yii for nesting?
$ 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 );

Similar to the above query (The above is incorrect, but the tags field cannot be found), can yii use ar to query? How do I perform this operation?


Reply to discussion (solution)

Is there a write rule in relation? Let's take a look at the source code of CActiveRecord. you can't use SQL directly.

It is easier to use createCommand.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.