index或者list页面数据汇总功能的用法

来源:互联网 发布:php简单商城源代码 编辑:程序博客网 时间:2024/06/06 21:41

在OA系统中经常会用到汇总的数据,以下的代码可以方便调用中的汇总功能

在index方法或者_before_index方法里加入如下

       $this->_count['field']['id']='count';// 统计个数据             $this->_count['field']['money']='sum';//合计数  $this->_count['group']['cat_id']='desc';//按照分类来统计 }
前台页面调用_count_list_这个变量进行循环,如果没有设置$this->_count['group']数组的话,就不不用循环输出

<foreach name="_count_list_" item="info">    <tr>    <td>{$file_category[$info[cat_id]]}</td>    <td>{$info[count_id]}</td>    </tr>  </foreach>

注意: $this->_count['field'][id]在变量中会作为count_id,他是根据其值是coun还是sum来决定。