Reputation: 7233
I am Using Mysqli Driver.
I am getting Command out of sync when i try to run the stored procedure. I have tried
free_result();
this is the snippet of my code can any 1 tell me the solution?
function block()
{
$qry = "CALL `sp_get_codes_by_block_id`(?)";
$result = $this->db->query($qry, $this->getBlockId());
$temp_array = array();
$temp_array = $result;
$result->free_result();
return $result->result_array();
}
Upvotes: 1
Views: 3455
Reputation: 559
try to use
while(mysqli_next_result($this->db->conn_id)) {
if($result = mysqli_store_result($this->db->conn_id)){
mysqli_free_result($result);
}
}
Upvotes: 0
Reputation: 7233
well i Actually figured out answer after alot of Brain storming and search.
$qry = "CALL `sp_get_codes_by_block_id`(?)";
$result = $this->db->query($qry, $this->getBlockId());
mysqli_next_result($this->db->conn_id);
return $result->result_array();
Upvotes: 4
Reputation: 96159
https://dev.mysql.com/doc/refman/5.0/en/c-api-multiple-queries.html says:
Multiple-result processing also is required if you execute CALL statements for stored procedures.
I.e. you have to go through all result sets via mysqli::more_results and free all of them.
Upvotes: 1