From: Operating system: Linux PHP version: 5.3SVN-2012-02-10 (SVN) Package: PDO related Bug Type: Feature/Change Request Bug description:PDOException::getCode() returns SQLSTATE instead of error code
Description: ------------ PDOException::getCode() returns the SQLSTATE instead of the error code. For example a var_dump of a random PDOException: object(PDOException)[97] protected 'message' => string 'SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction' (length=111) private 'string' (Exception) => string '' (length=0) protected 'code' => string '40001' (length=5) then the 'code' should not be the SQLSTATE (40001) but the error code (1213). My reason for this is that the SQLSTATE may not be unique, the error code is. For more info: http://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html Test script: --------------- Try to get a random PDOException with an invalid query. -- Edit bug report at https://bugs.php.net/bug.php?id=61040&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=61040&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=61040&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=61040&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=61040&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=61040&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=61040&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=61040&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=61040&r=needscript Try newer version: https://bugs.php.net/fix.php?id=61040&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=61040&r=support Expected behavior: https://bugs.php.net/fix.php?id=61040&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=61040&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=61040&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=61040&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=61040&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=61040&r=dst IIS Stability: https://bugs.php.net/fix.php?id=61040&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=61040&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=61040&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=61040&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=61040&r=mysqlcfg