}
var_dump($res->fetch_assoc());
?>
The above example will output:
array(1) {
["id"]=>
string(1) "1"
}
INOUT/OUT parameter
The values of
INOUT/OUT
Example 20.96. Using session variables
<?php
$mysqli = new mysqli("example.com", "user", "password", "database");
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
if (!$mysqli->query("DROP PROCEDURE IF EXISTS p") ||
!$mysqli->query('CREATE PROCEDURE p(OUT msg VARCHAR(50)) BEGIN SELECT "Hi!" INTO msg; END;')) {
echo "Stored procedure creation failed: (" . $mysqli->errno . ") " . $mysqli->error;
}
if (!$mysqli->query("SET @msg = ''") || !$mysqli->query("CALL p(@msg)")) {
echo "CALL failed: (" . $mysqli->errno . ") " . $mysqli->error;
}
if (!($res = $mysqli->query("SELECT @msg as _p_out"))) {
echo "Fetch failed: (" . $mysqli->errno . ") " . $mysqli->error;
}
$row = $res->fetch_assoc();
echo $row['_p_out'];
?>
The above example will output:
Hi!
Application and framework developers may be able to provide a more convenient API using a mix of
session variables and databased catalog inspection. However, please note the possible performance
impact of a custom solution based on catalog inspection.
Handling result sets
Stored procedures can return result sets. Result sets returned from a stored procedure cannot be
fetched correctly using mysqli_query. The
and fetching the first result set into a buffered result set, if any. However, there are additional stored
procedure result sets hidden from the user which cause
expected result sets.
MySQL Improved Extension (Mysqli)
parameters are accessed using session variables.
mysqli_query
2325
function combines statement execution
to fail returning the user
mysqli_query
Need help?
Do you have a question about the 5.0 and is the answer not in the manual?
Questions and answers