Re: mysqli_multi_query error tolerance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux