Bug #61613 [Com]: No PDO error if first SQL statement of a group is valid.

From: Date: Tue, 16 Jun 2015 15:51:22 +0000
Subject: Bug #61613 [Com]: No PDO error if first SQL statement of a group is valid.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193570@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=61613&edit=1 ID: 61613 Comment by: blaimi at blaimi dot de Reported by: trebitzki at gmx dot net Summary: No PDO error if first SQL statement of a group is valid. Status: Assigned Type: Bug Package: PDO MySQL Operating System: Mac OS X PHP Version: 5.3.10 Assigned To: mysql Block user comment: N Private report: N New Comment: I'm using this as workaround: $pdo->beginTransaction(); try { $statement = $pdo->prepare($sql); $statement->execute(); while ($statement->nextRowset()) {/* https://bugs.php.net/bug.php?id=61613 */}; $pdo->commit(); } catch (\PDOException $e) { $pdo->rollBack(); throw $e; } Previous Comments: ------------------------------------------------------------------------ [2015-04-14 14:12:42] mikhail dot v dot gavrilov at gmail dot com This bug still not fixed in PHP 5.6.7 Linux Fedora 21 ------------------------------------------------------------------------ [2014-10-13 10:26:45] pesterhazy at gmail dot com Though it is possible to run multiple statements using mysqli::multi_query, with PDO it just doesn't work. For example, if you exec() a string containing multiple INSERT statements, only the first statement will be executed. No exception is thrown (PHP 5.5.17, MySQL server 5.5.38). This is a bug. Running multiple SQL statements is useful, among other things, for creating stored procedures. ------------------------------------------------------------------------ [2014-09-29 16:34:29] trebitzki at gmx dot net The test script I included in my original bug report for this issue was only a simple example. I actually had this issue with a set of SQL UPDATE statements, so showing how fetching rows and looping through result sets obviates this is not really addressing the issue. When my first update statement runs successfully I can't call nextrowset(); the statements just run one after the other. The problem with not getting error info for any following statement that may fail still stands. And I must say that I am very surprised and disappointed that noone in the php group is willing to come to grips with this - after more than 2 1/2 years! ------------------------------------------------------------------------ [2014-09-24 16:38:09] benjamin dot morel at gmail dot com @rquadling Genius! Indeed, just tested it on a PDO configured to throw exceptions, and the PDOException is thrown as soon as nextRowSet() is called! When it's configured to *not* throw exceptions, as you guessed, the error information becomes available with PDOStatement::getErrorInfo(). So there's no bug after all, the behaviour of PHP is perfectly fine, maybe we could just mention this on the PDO error handling page in the docs? http://php.net/manual/en/pdo.error-handling.php Thanks so much. ------------------------------------------------------------------------ [2014-09-24 15:32:37] rquadling@php.net As the query contains multiple result sets, what is the response if you actually take a look at the next rowset using PDOStatement::nextRowSet() in conjunction with PDOStatement::errorInfo() / PDOStatement::errorCode()? ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=61613 -- Edit this bug report at https://bugs.php.net/bug.php?id=61613&edit=1

« previous php.bugs (#193570) next »