Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

codeigniter

I applied all the possible answers but still same problem. also tried

$this->db->reconnect();

there is no problem in my query

enter image description here

MyCode:

public function GetdistributorsDetails($username){
        $sql = "SELECT u.FirstName, u.Email, u.Telephone, u.MobileNumber, u.AlternateMobileNumber, ud.Address1, ud.Pincode,ud.City,s.Statename FROM users u JOIN userdetails ud ON ud.UserId = u.UserId JOIN states s ON s.StateId = ud.StateId WHERE u.Username = ? ";
        $result = $this->db->query($sql,array($username));
        return $result->result_array();
    }
like image 394
Juned Ansari Avatar asked Nov 28 '22 16:11

Juned Ansari


1 Answers

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;
like image 78
Juned Ansari Avatar answered May 29 '23 03:05

Juned Ansari