Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/64.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_Stored Procedures - Fatal编程技术网

Php 试图';呼叫';使用CodeIgniter的存储过程

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

我在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', '@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循环,您测试过它不工作吗?