2011-12-01 27 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可能已經跑了環,結果全部被釋放反正...