note 102837 added to mysqli.multi-query
| From: | jcn50 at osu1 dot php dot net | Date: | Wed, 09 Mar 2011 13:09:41 +0000 |
| Subject: | note 102837 added to mysqli.multi-query | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-177685@lists.php.net to get a copy of this message | ||
WATCH OUT: if you mix $mysqli->multi_query and $mysqli->query, the latter(s) won't be
executed!
<?php
// BAD CODE:
$mysqli->multi_query(" Many SQL queries ; "); // OK
$mysqli->query(" SQL statement #1 ; ") // not executed!
$mysqli->query(" SQL statement #2 ; ") // not executed!
$mysqli->query(" SQL statement #3 ; ") // not executed!
$mysqli->query(" SQL statement #4 ; ") // not executed!
?>
The only way to do this correctly is:
<?php
// WORKING CODE:
$mysqli->multi_query(" Many SQL queries ; "); // OK
while ($mysqli->next_result()) {;} // flush multi_queries
$mysqli->query(" SQL statement #1 ; ") // now executed!
$mysqli->query(" SQL statement #2 ; ") // now executed!
$mysqli->query(" SQL statement #3 ; ") // now executed!
$mysqli->query(" SQL statement #4 ; ") // now executed!
?>
----
Server IP: 69.147.83.197
Probable Submitter: 87.198.254.82
----
Manual Page -- http://www.php.net/manual/en/mysqli.multi-query.php
Edit -- https://master.php.net/note/edit/102837
Del: integrated -- https://master.php.net/note/delete/102837/integrated
Del: useless -- https://master.php.net/note/delete/102837/useless
Del: bad code -- https://master.php.net/note/delete/102837/bad+code
Del: spam -- https://master.php.net/note/delete/102837/spam
Del: non-english -- https://master.php.net/note/delete/102837/non-english
Del: in docs -- https://master.php.net/note/delete/102837/in+docs
Del: other reasons-- https://master.php.net/note/delete/102837
Reject -- https://master.php.net/note/reject/102837
Search -- https://master.php.net/manage/user-notes.php