Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何对codeigniter数据库类中的列求和?_Php_Mysql_Codeigniter_Mysqli_Codeigniter 2 - Fatal编程技术网

Php 如何对codeigniter数据库类中的列求和?

Php 如何对codeigniter数据库类中的列求和?,php,mysql,codeigniter,mysqli,codeigniter-2,Php,Mysql,Codeigniter,Mysqli,Codeigniter 2,如果日期介于某个预定义日期之间,我希望对列数据求和 我用核心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' a

如果日期介于某个预定义日期之间,我希望对列数据求和

我用核心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' ");