0

I am using mysql version in codeigniter and applied stored procedure for one of database operation and after running this . i want to run another query . so how can i run other query below the store procedure or close the connection

getting this error

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

here is additional code

This is my store procedure

$ret = $CI->db->query("call test_type($item_id,$test_id)");
now I want to run this query
$query = $CI->db->query("SELECT * FROM testing WHERE testing.test_type in  ('" . $test_id . "') AND testing.test_item_id =  '" . $item_id . "' ORDER BY testing.test_date DESC LIMIT 1");

Thanks in advance

Rajat Gupta
  • 342
  • 2
  • 12
  • 1
    Please show us all the relevant code. – M. Eriksson May 11 '17 at 05:50
  • This is my store procedure $ret = $CI->db->query("call test_type($item_id,$test_id)"); now I want to run this query $query = $CI->db->query("SELECT * FROM testing WHERE testing.test_type in ('" . $test_id . "') AND testing.test_item_id = '" . $item_id . "' ORDER BY testing.test_date DESC LIMIT 1"); – Rajat Gupta May 11 '17 at 05:51
  • 1
    You should also update your question instead of posting additional code in comments. It's quite unreadable. – M. Eriksson May 11 '17 at 05:52

1 Answers1

0

Try this.

Reference link.I am also facing error like you and solved using below code.

add following code into /system/database/drivers/mysqli/mysqli_result.php

 function next_result()
 {
     if (is_object($this->conn_id))
     {
         return mysqli_next_result($this->conn_id);
     }
 }

then in model when you call Stored Procedure

$sql    = $this->db->query("CALL getCityList()");
$result      = $sql->result();

//add this two line 
$sql->next_result(); 
$sql->free_result(); 
//end of new code

return $result;
Community
  • 1
  • 1
Nidhi
  • 1,529
  • 18
  • 28