Codeigniter Error Out of sync; Error Code 2014

A Database Error Occurred

Error Number: 2014
Commands out of sync; you can't run this command now
call sp_TotalTicketRegionDaily("2017-10-2")
Filename: modules/home/models/Mhome.php
Line Number: 41


Solution

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
$query    = $this->db->query("CALL test()");
$res      = $query->result();

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

return $res;

Komentar