Welcome Guest, Not a member yet? Register   Sign In
Commands out of sync; you can't run this command now (with free_result())
#1

Here is the code:
   $sql = "call getCase('$myTable', '$casenum', '$fname','$lname')";    
   $q = $this->db->query($sql);    
   $data['hrg'] = $q->result(); // $hrgs
   $q->free_result(); // http://www.codeigniter.com/user_guide/da...sults.html

When I execute the next query I get the commands out of sync error.
It looks to me like it is coded correctly. Any ideas of the problem?
Reply
#2

(This post was last modified: 02-04-2016, 12:44 AM by skunkbad.)

See this on my website:

http://community-auth.com/blog-posts/com...procedures


PHP Code:
$sql "call getCase( '$myTable', '$casenum', '$fname', '$lname')";    
$q 
$this->db->query($sql);    
$data
['hrg'] = $q->result();
/**
 * Free result is not good enough, because procedures 
 * will often return more than one result. The solution
 * is to use mysqli_next_result(). If you're not using
 * mysqli, then you're going to need to figure out how 
 * to get the next result using some other way.
 */
mysqli_next_result$this->db->conn_id ); 
Reply
#3

My solution.

\system\database\DB_result.php 

....
public function result_array()
{
              .....
              is_null($this->row_data) OR $this->data_seek(0);
              if($this->conn_id->affected_rows > 0) {// My custom
                    while ($row = $this->_fetch_assoc())
                    {
                            $this->result_array[] = $row;
                    }
                    $this->free_result(); // My custom
                    @mysqli_next_result($this->conn_id); // My custom
              }

              return $this->result_array;
}
Reply
#4

You should never edit and write to a CodeIgniter system file NEVER!
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(08-27-2016, 10:32 AM)InsiteFX Wrote: You should never edit and write to a CodeIgniter system file NEVER!

so it would be best practice then to extend and/or override the method in DB_Driver, then?

--- OM
OM...

-------------------------
And on the pedestal these words appear:
'My name is Ozymandias, king of kings:
Look on my works, ye Mighty, and despair!'
Nothing beside remains. Round the decay
Of that colossal wreck, boundless and bare
The lone and level sands stretch far away.
Reply
#6

Correct, the CodeIgniter system folder should never be touched because of updating it by coping the the new system folder over the old one.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#7

(08-29-2016, 09:22 AM)ozzy mandiaz Wrote:
(08-27-2016, 10:32 AM)InsiteFX Wrote: You should never edit and write to a CodeIgniter system file NEVER!

so it would be best practice then to extend and/or override the method in DB_Driver, then?

--- OM

Good luck with that. Unless something changed, extending the database classes has never been easy.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB