[eluser]Tim Brownlaw[/eluser]
I simply added the following into mysqli_result.php that is missing this command for some strange reason.
(under /system/database/drivers/mysqli/mysqli_result.php)
Code:
// --------------------------------------------------------------------
/**
* Read the next result
*
* @return null
*/
function next_result()
{
if (is_object($this->conn_id))
{
return mysqli_next_result($this->conn_id);
}
}
// --------------------------------------------------------------------
Then in my model, I simply call $result->next_result() to loose the expected extraneous resultset;
As an example, I have a stored procedure for adding a new member which I call in a model as the following function call.
Code:
// Calling Stored procedure add_reg_member
// Returns an array in the form...
// $row['result'] ( 0 = success )
// $row['message'] (if there is an error - why)
// $row['last_id'] - last insert id (could test this instead of result, but let's stay consistent)
function add_reg_member($db_data)
{
// using the active record structure to test it
$sql = 'CALL member_register(?,?,?,?,?,?,?,?,?)';
$params =array(
$db_data['username'],
$db_data['firstname'],
$db_data['lastname'],
$db_data['email'],
$db_data['password'],
$db_data['country'],
$db_data['validation_code'],
$db_data['date_reg'],
$db_data['valid'] );
$result = $this->db->query($sql,$params);
if(($result) && ($result->num_rows() > 0))
{
$row = $result->row_array();
}
else
$row =array('result'=>1,'message'=>'Something went horribly wrong with the DB','last_id'=>0); // Database Problem - die gracefully.
$result->next_result(); // Dump the extra resultset.
$result->free_result(); // Does what it says.
return $row; // Return the row to the controller that called it.
}
My stored procedure, while performing an insert, returns a few values I want to test and use.
For instance, when a duplicate username is encountered and the last inserted id.
So adding in the actual mysqli_next_result into mysqli_result.php fixed up all my problems. Well my CI ones
Plus I can still use the active record stuff...
I'm not sure why this isn't in CI already. I checked version 1.7.1 and it's not there.
Hope that helps someone!
Now, what was I doing a few hours ago before I got stuck on this?