Welcome Guest, Not a member yet? Register   Sign In
Command out of sync
#3

[eluser]Yauhen_S[/eluser]
Hi! I was solve this problem in other way. Below is a _execute method code:

Code:
// Free result from previous query
   @mysqli_free_result($this->result_id);
        
   $sql = $this->_prep_query($sql);

   // get a result code of query (), can be used for test is the query ok
   $retval = @mysqli_multi_query($this->conn_id, $sql);

   // get a first resultset
   $firstResult = @mysqli_store_result($this->conn_id);

   // free other resultsets
   while (@mysqli_next_result($this->conn_id)) {
      $result = @mysqli_store_result($this->conn_id);
      @mysqli_free_result($result);
   }

   // test is the error occur or not
   if (!$firstResult && !@mysqli_errno($this->conn_id)) {
       return true;
   }
   return $firstResult;

About check for error in last lines. This is because mysqli_store_result can return false not only if error occur, but also if query don't return resultset. Unfortunately CI checks only returned value for false and in this case "Error Number: 0" occures.

PS: I'm not sure that this will works with regular query, i'm using only stored routines in my current project.


Messages In This Thread
Command out of sync - by El Forum - 03-09-2008, 09:40 AM
Command out of sync - by El Forum - 04-02-2008, 01:57 PM
Command out of sync - by El Forum - 06-16-2008, 10:39 AM
Command out of sync - by El Forum - 04-13-2009, 01:07 AM
Command out of sync - by El Forum - 06-27-2009, 07:52 PM
Command out of sync - by El Forum - 08-08-2011, 06:30 AM
Command out of sync - by El Forum - 08-08-2011, 09:40 PM
Command out of sync - by El Forum - 08-09-2011, 02:58 AM
Command out of sync - by El Forum - 06-05-2014, 04:04 AM
Command out of sync - by El Forum - 06-05-2014, 12:07 PM
Command out of sync - by El Forum - 06-05-2014, 03:03 PM



Theme © iAndrew 2016 - Forum software by © MyBB