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

前端 未结 4 427
灰色年华
灰色年华 2020-12-06 03:54

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

$this->db->reconnect();

there is no problem in my query

<
相关标签:
4条回答
  • 2020-12-06 03:56

    Just use this one if you use multiple query make in same function: $this->db->close();

    0 讨论(0)
  • 2020-12-06 03:57

    If your stored procedure returns more than one result, try to add this code between the queries:

    $storedProcedure = 'CALL test(inputParam, @outputParam)';
    $this->db->query($storedProcedure);    
    
    $conn = $this->db->conn_id;
    do {
        if ($result = mysqli_store_result($conn)) {
            mysqli_free_result($result);
        }
    } while (mysqli_more_results($conn) && mysqli_next_result($conn));
    
    $sql = 'SELECT @outputParam;';
    $this->db->query($sql); 
    
    0 讨论(0)
  • 2020-12-06 04:05

    you can use this after call

    mysqli_next_result( $this->db->conn_id );
    
    0 讨论(0)
  • 2020-12-06 04:15

    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;
    
    0 讨论(0)
提交回复
热议问题