MySQL Forums
Forum List  »  PHP

Retrieving out variables from procedure
Posted by: David .
Date: April 29, 2012 11:59AM

Hello!

As I have understood it you can either return a resultset from the procedure (SELECT out_variable1, out_variable2, out_variable3 inside the procedure) or access the OUT variables.

I want to know which is (if it any) the preferred way to access OUT varables from a procedure into PHP.

Also I have some issues with my code, which I'm not sure is correct. It works but executes with a warning:
PHP Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in ... (@ the first mysqli_free_result($result)).

I'm not sure if I just can remove mysqli_free_result: Also I don't want to ignore this warning since it will arise in every procedure I want to retrive varaibles from. How will a proper retrival of the OUT variables look (that is fast and not produces warnings)?

MY CODE:

$query_procedure = "CALL GET_PROCEDURE($in_variable, @out_variable1, @out_variable2, @out_variable3);SELECT @out_variable1, @out_variable2, @out_variable3";


if(mysqli_multi_query($mysql_connection, $query_procedure))
{
$result = mysqli_use_result($mysql_connection);
mysqli_free_result($result);
mysqli_next_result($mysql_connection);
$result = mysqli_use_result($mysql_connection);
$row = mysqli_fetch_assoc($result);
mysqli_free_result($result);
}

$result1 = $row['@out_variable1'];
$result2 = $row['@out_variable2'];
$result3 = $row['@out_variable3'];

Options: ReplyQuote


Subject
Written By
Posted
Retrieving out variables from procedure
April 29, 2012 11:59AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.