Welcome Guest, Not a member yet? Register   Sign In
Commands out of sync
#5

(This post was last modified: 07-02-2017, 02:13 PM by meSmashsta.)

What you're doing is calling more than 1 procedures which is a multi query equivalent of php I think, and according to the documentation of mysql:

Quote:If you get Commands out of sync; you can't run this command now in your client code,
you are calling client functions in the wrong order.
This can happen, for example, if you are using mysql_use_result() and try to execute a new query
before you have called mysql_free_result(). It can also happen if you try to execute two queries
that return data without calling mysql_use_result() or mysql_store_result() in between.

That's the solution for C, and the equivalent for php is to call mysqli_next_result function which takes the mysqli connection as a parameter. You have to call that in between your procedure calls. Like this:

PHP Code:
function get_degree_dropdown(){
 
      $query$this->db->query("call getDegree_master()");
 
      mysqli_next_result($this->db->conn_id);
 
      return $query->result();
 
  }

public function 
get_doctor_details_by_id($doctor_id)
 
  {
 
      $query$this->db->query('call get_DoctorDetaisById('.$doctor_id.')');
 
      mysqli_next_result($this->db->conn_id);
 
      return $query->result();
 
  

Also, it's a good practice to free your result resource like this:

PHP Code:
$query->free_result(); 
But don't forget to save the data first before freeing.
PHP Code:
$query$this->db->query('call get_DoctorDetaisById('.$doctor_id.')');
...
$data $query->result();
$query->free_result();
return 
$data
Reply


Messages In This Thread
Commands out of sync - by debajyoti.saha09 - 01-14-2015, 12:46 AM
RE: Commands out of sync - by Rufnex - 01-14-2015, 02:32 AM
RE: Commands out of sync - by skunkbad - 01-15-2015, 02:21 AM
RE: Commands out of sync - by mehmood sanjrani - 03-01-2016, 11:21 AM
RE: Commands out of sync - by meSmashsta - 01-08-2017, 11:40 PM
RE: Commands out of sync - by dimas - 03-21-2017, 04:24 AM



Theme © iAndrew 2016 - Forum software by © MyBB