Thanks for responding, Chris. If I understand you right, you're saying that this is MySQL API issue, right? But do you agree that mysqli_multi_query should at least accept a parameter to configure how to treat errors -- for example: RESUME_ON_ERROR, or ABORT_ON_ERROR? If you and other's in this list share my view on this I'll send a feature suggestion to MySQL AB. Here goes my my test script: <?php /// Filipe Martins MAISQI.COM [2009-04-06] /// http://www.maisqi.com /// /// I'm trying to demonstrate that 'mysqli_multi_query' aborts all the following statements /// after an error. Or maybe it runs it but ignores the results. Didn't test this possibilitie. /// /// I think it should report the error but continue working. Better yet, there should be a way /// for us to control this behavior. /// $host = 'localhost'; $user = 'root'; $pwd = '36981613'; $db = 'test'; $conn = mysqli_connect ($host, $user, $pwd, $db); // The 2nd statement should fail but he others should work. $sql = "SELECT -1;SELECT 0 FROM xyzzyz;SELECT 123;SELECT 'All ok'"; $res = mysqli_multi_query ($conn, $sql); $i = 0; do { ++$i; // Let's read this result. if ($res = mysqli_store_result ($conn)) { $a = mysqli_fetch_row ($res); $s = print_r ($a, true); echo "Statement #$i worked: $s\n<br />"; mysqli_free_result ($res); } else echo "Statement #$i failed\n<br />"; // Try to read until there's no more. } while (mysqli_next_result ($conn) || mysqli_more_results ($conn)); echo "\n<br />"; if ($i < 4) echo "We finished quite early, didn't we?!\n<br />"; else echo "What?? It worked?!\n<br />"; Chris writes: > Filipe Martins wrote: >> Hello. >> I have a doubt about mysqli_multi_query and I couldn't find >> anything on the Internet addressing it. >> I think that mysqli_multi_query should execute all statements >> even if some of them fail. As far as I can tell this doesn't >> happen. The function stops returning results the moment it finds >> an error. > > The same happens in php, c, bash, java and everything else. > > <?php > function do_stuff() > { > echo "in do_stuff\n"; > return false; > } > > function do_more_stuff() > { > echo "in do_more_stuff\n"; > return true; > } > > if (do_stuff() && do_more_stuff()) { > echo "all done!\n"; > } > > do_more_stuff() will never run because do_stuff() is broken returns a > non-success status. > > This behaviour would be driven by mysql anyway, not php - the same thing > happens in postgres (where I can include an example more easily). > > # begin; > BEGIN > Time: 0.723 ms > > *# select now(); > now > ------------------------------- > 2009-04-07 08:52:07.986149+10 > (1 row) > > Time: 99.173 ms > > *# select field_from_table; > ERROR: column "field_from_table" does not exist > LINE 1: select field_from_table; > ^ > !# select now(); > ERROR: current transaction is aborted, commands ignored until end of > transaction block > > The whole thing is aborted because of the error. > >> I attached a test file proving my point. I ask your help for >> figuring out if this is a bug, a limitation of the function, or >> if simply it's my mistake. > > The mailing list doesn't accept attachments, you'll need to include it > inline with your email (as long as it's not too long) or place it > somewhere for everyone to see and send us a link. > > -- > Postgresql & php tutorials > http://www.designmagick.com/ > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > ----------------------------------------------------------------------------------------------------------------------- Send big files for free. Simple steps. No registration. Visit now http://www.nawelny.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php