2011-12-01 37 views
1

如何使用?PHP中的Codeigniter和Mysql过程

我的程序库

<?php if (! defined('BASEPATH')) exit('No direct script access allowed'); 

    class Procedure 
    { 
     var $CI; 
     public $result = NULL; // Dönen Değer Değişkeni 

     public function __construct() 
     { 
      $this->CI = & get_instance(); 

     } 

     public function query($sql) 
     { 
      // Sql Sorgusunu Çalıştır Sonucu resulta At 
      $this->result = $this->CI->db->query($sql); 
      // Procedure İçin Yazılmış 
      while(mysqli_next_result($this->CI->db->conn_id)){ 
       if($l_result = mysqli_store_result($this->CI->db->conn_id)){ 
        mysqli_free_result($l_result); 
       } 
      } 
      // Procedure İçin Yazılmış  
      // Sonucu Döndür 
      return $this->result;  
     } 
    } 
?> 

1 - 2查询和结果:没问题

4 - 5查询和结果:

Commands out of sync; you can’t run this command now 

没有一个确切的结果?供使用

+3

这真的很难理解你的问题,请尝试使用适当的英语句子。 – talnicolas

+0

mmmh ya ...不是更好... – talnicolas

回答

0

为什么不直接返回CI结果对象?

$this->result = $this->CI->db->query($sql, TRUE)->result(); 

...而不是使用你的while循环? CI可能已经跑了环,结果全部被释放反正...