如何对 codeigniter 数据库中的列求和 class?
how to sum of column in codeigniter database class?
如果日期介于某个预定义日期之间,我想对列数据求和。
我用核心做这个 php 就像
SUM(IF(`trl`.`entrydate` between '2015-01-01' and '2015-01-31', `trl`.`itemvalue`, 0))
那么我如何使用 codeigniter 做到这一点
有活动记录:
$this->db->select_sum('data');
$this->db->where("entrydate between 'x' and 'y' ");
$query = $this->db->get('your table');
有查询:
$this->db->query("select SUM(data) from `your table` where entrydate between 'x' and 'y' ");
如果日期介于某个预定义日期之间,我想对列数据求和。
我用核心做这个 php 就像
SUM(IF(`trl`.`entrydate` between '2015-01-01' and '2015-01-31', `trl`.`itemvalue`, 0))
那么我如何使用 codeigniter 做到这一点
有活动记录:
$this->db->select_sum('data');
$this->db->where("entrydate between 'x' and 'y' ");
$query = $this->db->get('your table');
有查询:
$this->db->query("select SUM(data) from `your table` where entrydate between 'x' and 'y' ");