From: akorthaus at web dot de Operating system: Linux 2.4.32 (gentoo) PHP version: 5.1.2 PHP Bug Type: PDO related Bug description: PDO does not throw Exception
Description: ------------ The following code leads to a "Unknown Command" Error (because I tried to use PDO with a 5.0 libmysql to connect to a 3.23 mysqld), but for any reason this does not throw an Ecxeption, though I used: $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); Why doesn't PDO throw an Exception here? Reproduce code: --------------- <?php try { $dbh = new PDO('mysql:host=localhost;dbname=test', 'user', 'pass'); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $result = $dbh->query('SELECT * FROM test'); var_dump($dbh->errorInfo()); } catch(PDOException $e){ die($e->getMessage()); } ?> Expected result: ---------------- should throw a PDOEception ("Unknown Command"), which is caused by PDO::query(). Actual result: -------------- Does not throw any exception, only $dbh->errorInfo() gives some info here. $dbh->query() return FALSE $dbh->errorInfo() returns error "Unknown Command" $dbh->getAttribute(PDO::ATTR_ERRMODE) returns "2" which is == PDO::ERRMODE_EXCEPTION shouldn't PDO throw an Exception here? Seems to ignore the errormode set by $dbh->setAttribute(). Before calling $dbh->query() and after calling $dbh->setAttribute() $dbh->errorInfo() returns no error. I started a thread on php.pecl.dev last week about a problem with using PDO_MYSQL linked against a 5.0 libmysql with a 3.23 mysqld. The reason for the error seems to be, that PDO_MYSQL uses "prepare" internally, which is not supported by mysqld <4.1: http://marc.theaimsgroup.com/?t=114319999400001&r=1&w=2 -- Edit bug report at http://bugs.php.net/?id=36890&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=36890&r=trysnapshot44 Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=36890&r=trysnapshot51 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=36890&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=36890&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=36890&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=36890&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=36890&r=needscript Try newer version: http://bugs.php.net/fix.php?id=36890&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=36890&r=support Expected behavior: http://bugs.php.net/fix.php?id=36890&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=36890&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=36890&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=36890&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36890&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=36890&r=dst IIS Stability: http://bugs.php.net/fix.php?id=36890&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=36890&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=36890&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=36890&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=36890&r=mysqlcfg