PHP 8.5.0 Alpha 4 available for testing

Voting

: max(three, five)?
(Example: nine)

The Note You're Voting On

st dot john dot johnson at gmail dot com
18 years ago
In reference to what lachlan76 said before, stored procedures CAN be executed through prepared statements as long as you tell the DB to move to the next result before executing again.

Example (Five calls to a stored procedure):

<?php
for ($i=0;$i<5;$i++) {
$statement = $mysqli->stmt_init();
$statement->prepare("CALL some_procedure( ? )");

// Bind, execute, and bind.
$statement->bind_param("i", 1);
$statement->execute();
$statement->bind_result($results);

while(
$statement->fetch()) {
// Do what you want with your results.
}

$statement->close();

// Now move the mysqli connection to a new result.
while($mysqli->next_result()) { }
}
?>

If you include the last statement, this code should execute without the nasty "Commands out of sync" error.

<< Back to user notes page

To Top