码迷,mamicode.com
首页 > 其他好文 > 详细

关于Yii2中count方法的使用

时间:2015-07-31 21:37:34      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:

统计文章与分类中间表中c_id的数目,也就是category表中total字段的值

原生SQL语句:select count(c_id) from article_category where c_id=1;

 

原来错误的写法:

技术分享

正确的写法:

ArticleCategory::find()->where([‘c_id‘=>$id])->count(‘c_id‘);

关于Yii2中count方法的使用

标签:

原文地址:http://www.cnblogs.com/toward-the-sun/p/4693068.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!