Welcome Guest, Not a member yet? Register   Sign In
Mysqli Library - changes
#1

[eluser]safarath[/eluser]
Issue related to MYSQLI library and using stored procedure .
free_result() is not good enough to handle freeing stored procedure result set.
you will get error if you try to connect / fetch data from database again after you call the stored procedure even if you free the result using CI.
[b]Error Number: 2014
Commands out of sync; you can't run this command no
w[/b]


I have made small change in database/drivers/mysqli/mysqli_result.php function free_result()
to as below.


function free_result()
{

if (is_object($this->result_id)) {
mysqli_free_result($this->result_id);
/*
Edited by Safarath sk in order to free the mysqli multiple set results.
Date: 23/01/2011
*/
while ($this->conn_id->next_result()) {
/*free each result.*/
$result = $this->conn_id->use_result();
if ($result instanceof mysqli_result) {
$result->free();
}
}
$this->result_id = false;
}
}


its working fine now.
It will help some one using CI and Stored procedure.
CI can put it in new release.
#2

[eluser]InsiteFX[/eluser]
Did you know that CI has a flag that is set to TRUE to save queries?

$save_queries = TRUE;

InsiteFX
#3

[eluser]volition23[/eluser]
Yes, this has been an issue for a while. It's easy enough to fix though.

Given the new CI 2.0 codebase, go to system/database/drivers/mysqli/mysqli_driver.php

and make your _execute function look like this:

function _execute($sql)
{
$sql = $this->_prep_query($sql);
$result = @mysqli_query($this->conn_id, $sql);
@mysqli_next_result($this->conn_id);
return $result;
}

That's a one line change to add the @mysqli_next_result call.

Changing the $save_queries value doesn't have an effect on this.
#4

[eluser]Unknown[/eluser]
if you add
Quote:@mysqli_next_result($this->conn_id);

it will break the affected_rows method.




Theme © iAndrew 2016 - Forum software by © MyBB