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

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

 

原来错误的写法:

关于Yii2中count方法的使用

正确的写法:

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

相关文章:

  • 2021-09-04
  • 2022-01-11
  • 2022-12-23
  • 2022-12-23
  • 2021-06-02
  • 2021-09-17
  • 2021-10-14
猜你喜欢
  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
  • 2022-01-17
  • 2021-12-11
  • 2021-10-02
  • 2022-01-04
相关资源
相似解决方案