Php 试图';呼叫';使用CodeIgniter的存储过程
我在CI中使用了以下工作代码:Php 试图';呼叫';使用CodeIgniter的存储过程,php,mysql,codeigniter,stored-procedures,Php,Mysql,Codeigniter,Stored Procedures,我在CI中使用了以下工作代码: $this->db->query("call nameOfProcedure('param1', @param2)"); $query = $this->db->query('SELECT @param2 as results'); $row = $query->row(); 它可以工作,但如果我尝试使用: $this->db->call_function('nameOfProcedure', 'param1', '@p
$this->db->query("call nameOfProcedure('param1', @param2)");
$query = $this->db->query('SELECT @param2 as results');
$row = $query->row();
它可以工作,但如果我尝试使用:
$this->db->call_function('nameOfProcedure', 'param1', '@param2');
我得到一个错误:
此功能不适用于您正在使用的数据库
到底怎么了
谢谢查看打开呼叫功能
。它用于调用不是CI的DB驱动程序所固有的函数,而不是调用您编写的过程
您可以在CI 2.1.0的
/system/database/DB_driver.php
ln998中检查call_函数
code,以清楚地了解它在做什么。以防它对任何人都有帮助。我使用这个库处理CI中的存储过程,它也支持多个结果集
这是密码
我称之为Mydb.php
<?php #if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Mydb
{
private $CI, $Data, $mysqli, $ResultSet;
/**
* The constructor
*/
function __construct()
{
$this->CI =& get_instance();
$this->Data = '';
$this->ResultSet = array();
$this->mysqli = $this->CI->db->conn_id;
}
public function GetMultiResults($SqlCommand)
{
/* execute multi query */
if (mysqli_multi_query($this->mysqli, $SqlCommand)) {
$i=0;
do
{
if ($result = $this->mysqli->store_result())
{
while ($row = $result->fetch_assoc())
{
$this->Data[$i][] = $row;
}
mysqli_free_result($result);
}
$i++;
}
while ($this->mysqli->next_result());
}
return $this->Data;
}
}
?>
$db['default']['dbdriver'] = 'mysqli';
另外,确保设置驱动程序mysqli
在application/config/database.php中
<?php #if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Mydb
{
private $CI, $Data, $mysqli, $ResultSet;
/**
* The constructor
*/
function __construct()
{
$this->CI =& get_instance();
$this->Data = '';
$this->ResultSet = array();
$this->mysqli = $this->CI->db->conn_id;
}
public function GetMultiResults($SqlCommand)
{
/* execute multi query */
if (mysqli_multi_query($this->mysqli, $SqlCommand)) {
$i=0;
do
{
if ($result = $this->mysqli->store_result())
{
while ($row = $result->fetch_assoc())
{
$this->Data[$i][] = $row;
}
mysqli_free_result($result);
}
$i++;
}
while ($this->mysqli->next_result());
}
return $this->Data;
}
}
?>
$db['default']['dbdriver'] = 'mysqli';
不知道为什么你没有选择正确的答案。文档清楚地说明了它是用来调用PHP数据库函数的。该库只支持返回多个结果集,如果一个过程只返回一个结果ret,则将抛出错误。要同时支持返回一个结果,必须将行“while($this->mysqli->next_result());”更改为“while($this->mysqli->more_results()&&&$this->mysqli->next_result());”@Stony是一个do while循环,您测试过它不工作吗?