Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/62.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
在select语句中添加两个值,其中一个值来自函数-codeigniter/php/mysql_Php_Mysql_Codeigniter_Stored Procedures - Fatal编程技术网

在select语句中添加两个值,其中一个值来自函数-codeigniter/php/mysql

在select语句中添加两个值,其中一个值来自函数-codeigniter/php/mysql,php,mysql,codeigniter,stored-procedures,Php,Mysql,Codeigniter,Stored Procedures,我有一个返回一个结果“3”的函数,还有一个主函数,它对数据库进行查询,在select语句中,我需要将值添加到select语句中 此查询从第一个函数返回一个值: function insert() { $siteid = 1; $field = 3; $time = "2011-10-11 15:04:56"; $this->db->select('Offset_value', 1) ->from('offset') ->where('siteid',

我有一个返回一个结果“3”的函数,还有一个主函数,它对数据库进行查询,在select语句中,我需要将值添加到select语句中

此查询从第一个函数返回一个值:

function insert() {
$siteid = 1;
$field = 3;
$time = "2011-10-11 15:04:56";
$this->db->select('Offset_value', 1)
     ->from('offset')
     ->where('siteid', $siteid)
     ->where('Offset_field', $field)
     ->where('time <', $time);
$query = $this->db->get()->result_array();

foreach ($query as $row) {
    echo $row['Offset_value'];
    }
return $query;

}
我试图重写一个在mssql中创建的存储过程,这就是它的工作原理,所以我尝试在这里使用相同的方法


谢谢

我认为php不喜欢引号中的$obj->方法语法。请为该选择行尝试以下操作:

$this->db->select("kwh * $dr * $kwp + ".$this->insert()." AS kwhdata")
$this->db->select("kwh * $dr * $kwp + ".$this->insert()." AS kwhdata")