ID: 44153 Updated by: [EMAIL PROTECTED] Reported By: uwendel at mysql dot com -Status: To be documented +Status: Closed Bug Type: PDO related Operating System: Linux PHP Version: 5.3CVS-2008-02-18 (CVS) Assigned To: davidc New Comment:
This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2008-11-22 20:16:32] [EMAIL PROTECTED] Documentation has been updated. ------------------------------------------------------------------------ [2008-11-04 18:30:22] [EMAIL PROTECTED] This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. ------------------------------------------------------------------------ [2008-11-01 19:57:42] [EMAIL PROTECTED] The patch below allows you to do: $error = $pdo->errorCode(); if (is_null($error)) { // There's an empty error... } http://dev.agoraproduction.com/php/5_3/ext/pdo/bug44153.patch More I look at it and more I think we should have a generic message like "UNUSED" or something similar but I think NULL is also quite straightforward. ------------------------------------------------------------------------ [2008-10-24 23:34:18] [EMAIL PROTECTED] What about returning NULL ? You could easily check the results using is_null() and if it's null that means there's no errorCode(). Whereas when there's an error code you'll get the usual sqlstate message/code. What do you think? I think NULL would make great sense. ------------------------------------------------------------------------ [2008-02-18 18:07:53] uwendel at mysql dot com Description: ------------ The PHP manual states that PDO->errorCode() returns the SQLSTATE associated with the last operation run on the handle, http://www.php.net/manual/en/function.PDO-errorCode.php "Return Values Returns a SQLSTATE, a five-character alphanumeric identifier defined in the ANSI SQL-92 standard. Briefly, an SQLSTATE consists of a two-character class value followed by a three-character subclass value. A class value of 01 indicates a warning and is accompanied by a return code of SQL_SUCCESS_WITH_INFO. Class values other than '01', except for the class 'IM', indicate an error. The class 'IM' is specific to warnings and errors that derive from the implementation of PDO (or perhaps ODBC, if you're using the ODBC driver) itself. The subclass value '000' in any class indicates that there is no subclass for that SQLSTATE. " What is PDO->errorCode() supposed to return if no operation has been run on the handle yet? If its valid to return any empty string, please add this to the documentation. Reproduce code: --------------- [EMAIL PROTECTED]:~/php53> sapi/cli/php -r '$pdo=new PDO("mysql:dbname=phptest;unix_socket=/tmp/mysql.sock", "root", "root"); var_dump($pdo->errorCode());' string(0) "" [EMAIL PROTECTED]:~/php53> sapi/cli/php -r '$pdo=new PDO("sqlite:/tmp/foo.db"); var_dump($pdo->errorCode());' string(0) "" Expected result: ---------------- Its a matter of taste. Personally I have a preference for returning '00000' as this makes checking the error code easier but this would be sort of a BC break. Actual result: -------------- Empty string (see above). ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44153&edit=1