|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-04-09 08:28 UTC] wez@php.net
[2006-04-09 12:31 UTC] akorthaus at web dot de
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 15:00:01 2025 UTC |
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