Thinkphp如何做分组统计

浏览:4824 发布日期:2018/07/09 分类:技术分享 关键字: 分组统计
Thinkphp3 框架练习:
统计每个文章分类下文章的的数量!应用知识Thinkphp手册、Mysql语法

$project = M('Article');
$list = $project->field('p.*,o.title,o.describe,count(1) as zcount')->alias('p')->join(' LEFT JOIN __CATEGORY__ o ON p.cat_id=o.id')->where($where)->group('p.cat_id')->select();

分组统计应用的场景很多:统计分类下的产品、分章、统计用户组下的用户数量等等。
原文已经附有:结合分页,筛选、时间 、统计的案例
http://suo.im/5dS1TC
最佳答案
评论( 相关
后面还有条评论,点击查看>>