note 75534 added to function.mysqli-stmt-prepare

From: Date: Mon, 04 Jun 2007 15:59:28 +0000
Subject: note 75534 added to function.mysqli-stmt-prepare
Groups: php.notes 
Request: Send a blank email to php-notes+get-127191@lists.php.net to get a copy of this message
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. ---- Server IP: 69.147.83.197 Probable Submitter: 63.208.148.254 ---- Manual Page -- http://www.php.net/manual/en/function.mysqli-stmt-prepare.php Edit -- https://master.php.net/note/edit/75534 Del: integrated -- https://master.php.net/note/delete/75534/integrated Del: useless -- https://master.php.net/note/delete/75534/useless Del: bad code -- https://master.php.net/note/delete/75534/bad+code Del: spam -- https://master.php.net/note/delete/75534/spam Del: non-english -- https://master.php.net/note/delete/75534/non-english Del: in docs -- https://master.php.net/note/delete/75534/in+docs Del: other reasons-- https://master.php.net/note/delete/75534 Reject -- https://master.php.net/note/reject/75534 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#127191) next »