You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.6 KiB
PHTML
53 lines
1.6 KiB
PHTML
5 years ago
|
<?php
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | OneThink [ WE CAN DO IT JUST THINK IT ]
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
|
||
|
// +----------------------------------------------------------------------
|
||
|
|
||
|
namespace Admin\Model;
|
||
|
use Think\Model;
|
||
|
|
||
|
/**
|
||
|
* 分类模型
|
||
|
*/
|
||
|
class SpendCountModel extends Model{
|
||
|
/**
|
||
|
* 构造函数
|
||
|
* @param string $name 模型名称
|
||
|
* @param string $tablePrefix 表前缀
|
||
|
* @param mixed $connection 数据库连接信息
|
||
|
*/
|
||
|
public function __construct($name = '', $tablePrefix = '', $connection = '') {
|
||
|
/* 设置默认的表前缀 */
|
||
|
$this->tablePrefix ='tab_';
|
||
|
/* 执行构造方法 */
|
||
|
parent::__construct($name, $tablePrefix, $connection);
|
||
|
}
|
||
|
/**
|
||
|
* 获取统计 $map,$page,$row
|
||
|
*/
|
||
|
public function getSpendCountData($map=[],$field='',$group='',$order='',$page = 0,$row = 0) {
|
||
|
if ($row == 0) {
|
||
|
$data = $this->field($field)->where($map)->group($group)->order($order)->select();
|
||
|
} else {
|
||
|
$data = $this->field($field)->where($map)->page($page,$row)->group($group)->order($order)->select();
|
||
|
}
|
||
|
|
||
|
return $data;
|
||
|
}
|
||
|
/**
|
||
|
* 获取某个字段的总和 $map,$field
|
||
|
*/
|
||
|
public function sumSpendCountField($map,$field) {
|
||
|
$sum = $this->where($map)->sum($field);
|
||
|
return $sum;
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|