💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
## 关于系统各种统计调用 > 主要方法还是使用系统数据库模型查询: > M([molds])->getCount([where]); > molds:表示模块表示 > where:表示查询条件 ### 统计所有显示文章数 ``` {php $articlenum = M('article')->getCount(['isshow'=>1]); /} 使用变量:{$articlenum} #isshow=1表示显示,isshow=0表示隐藏 ``` ### 统计所有显示商品数 ``` {php $productnum = M('product')->getCount(['isshow'=>1]); /} 使用变量:{$productnum} #isshow=1表示显示,isshow=0表示隐藏 ``` ### 统计所有留言数 ``` {php $messgnum= M('message')->getCount(['isshow'=>1]); /} 使用变量:{$messgnum} #isshow=1表示已审核,isshow=0表示未审核 ``` ### 统计指定文章/商品的所有评论数 ``` {php $plnum= M('comment')->getCount(['aid'=>1,'tid'=>1]); /} 使用变量:{$plnum} #aid=1表示内容ID为1,tid=1表示文章所属栏目为1 #该统计不区分文章还是商品,只跟栏目ID和内容ID相关 ``` ### 点赞统计 > 针对于内容页 > ``` > {fun jz_zan($jz['tid'],$jz['id'])} > ``` > 其他页面基于循环遍历变量`$v` (根据情况而定) > ``` > {fun jz_zan($v['tid'],$v['id'])} > ``` ### 收藏统计 > 针对于内容页 > ``` > {fun jz_collect($jz['tid'],$jz['id'])} > ``` > 其他页面基于循环遍历变量`$v` (根据情况而定) > ``` > {fun jz_collect($v['tid'],$v['id'])} > ``` ### 会员统计 ``` {php $membernum= M('member')->getCount(); /} 使用变量:{$membernum} ``` ### 统计某会员分组下的用户数 ``` {php $membernum= M('member')->getCount(['gid'=>1]); /} 使用变量:{$membernum} #gid=1表示分组ID为1 ``` ## 统计计算栏目文章数(包含子栏目) ``` {fun M($v['molds'])->getCount('isshow=1 and tid in('.implode(",",$classtypedata[栏目ID]["children"]["ids"]).')'); } 或 {php $num = M($v['molds'])->getCount('isshow=1 and tid in('.implode(",",$classtypedata[栏目ID]["children"]["ids"]).')'); /} {$num} #注意:栏目ID 需要换成你当前的变量,如:$v['id'] ``` ## 统计计算栏目文章数(不包含子栏目) ``` {fun M($v['molds'])->getCount(['isshow'=>1,'tid'=>栏目ID]); } 或 {php $num = M($v['molds'])->getCount(['isshow'=>1,'tid'=>栏目ID]); /} {$num} #注意:栏目ID 需要换成你当前的变量,如:$v['id'] ```