diff --git a/reference/pdo/constants.xml b/reference/pdo/constants.xml index 11c9686914..5c4b86ac17 100644 --- a/reference/pdo/constants.xml +++ b/reference/pdo/constants.xml @@ -1,5 +1,5 @@ - +
&reftitle.constants; @@ -133,7 +133,8 @@ Specifies that the fetch method shall return TRUE and assign the values of the columns in the result set to the PHP variables to which they were - bound with the PDOStatement::bindParam method. + bound with the PDOStatement::bindParam or + PDOStatement::bindColumn methods. @@ -144,7 +145,8 @@ - + Specifies that the fetch method shall return only a single requested + column from the next row in the result set. @@ -155,7 +157,8 @@ - + Specifies that the fetch method shall return a new instance of the + requested class, mapping the columns to named properties in the class. @@ -166,7 +169,8 @@ - + Specifies that the fetch method shall update an existing instance of the + requested class, mapping the columns to named properties in the class. diff --git a/reference/pdo/functions/PDO-errorCode.xml b/reference/pdo/functions/PDO-errorCode.xml index 15547f0390..4d73a2ac37 100644 --- a/reference/pdo/functions/PDO-errorCode.xml +++ b/reference/pdo/functions/PDO-errorCode.xml @@ -1,11 +1,11 @@ - + PDO::errorCode - Fetch the error code associated with the last operation on the database handle + Fetch the SQLSTATE associated with the last operation on the database handle @@ -21,7 +21,7 @@ &reftitle.returnvalues; - Returns a SQLSTATE, a five-character alphanumric identifier defined in the ANSI SQL + Returns a SQLSTATE, a five-character alphanumeric identifier defined in the ANSI SQL standard. diff --git a/reference/pdo/functions/PDO-errorInfo.xml b/reference/pdo/functions/PDO-errorInfo.xml index 46fbab7fe8..561d9769fa 100644 --- a/reference/pdo/functions/PDO-errorInfo.xml +++ b/reference/pdo/functions/PDO-errorInfo.xml @@ -1,5 +1,5 @@ - + @@ -27,30 +27,25 @@ - - Element - Information - + + Element + Information + - - 0 - SQLSTATE error code (a five-character alphanumeric identifier defined - in the ANSI SQL standard). - - - 1 - Driver-specific error code. - - - 2 - Driver-specific error message. - - - 3 - SQLSTATE error code (a five-character alphanumeric identifier defined - in the ANSI SQL standard). - + + 0 + SQLSTATE error code (a five-character alphanumeric identifier defined + in the ANSI SQL standard). + + + 1 + Driver-specific error code. + + + 2 + Driver-specific error message. + @@ -79,7 +74,7 @@ /* Provoke an error -- the BONES table does not exist */ $err = $dbh->prepare('SELECT skull FROM bones'); $err->execute(); -echo "\nPDOStatement::errorInfo():\n"; +echo "\nPDO::errorInfo():\n"; print_r($err->errorInfo()); ?> ]]> @@ -87,14 +82,12 @@ print_r($err->errorInfo()); &example.outputs; 42S02 [1] => -204 [2] => [IBM][CLI Driver][DB2/LINUX] SQL0204N "DANIELS.BONES" is an undefined name. SQLSTATE=42704 - (SQLExecute[-204] at /home/daniels/php/pecl/pdo_odbc/odbc_stmt.c:88) - [3] => 42S02 ) ]]> diff --git a/reference/pdo/functions/PDOStatement-errorCode.xml b/reference/pdo/functions/PDOStatement-errorCode.xml index d9cdb07166..2a276b7c3c 100644 --- a/reference/pdo/functions/PDOStatement-errorCode.xml +++ b/reference/pdo/functions/PDOStatement-errorCode.xml @@ -1,27 +1,36 @@ - + PDOStatement::errorCode - Fetch the error code associated with the last operation on the statement handle + Fetch the SQLSTATE associated with the last operation on the statement handle - - Description + + &reftitle.description; intPDOStatement::errorCode &warn.experimental.func; + + + &reftitle.returnvalues; - Returns an integer value that maps to the error categories defined - in the PDO constants. + Returns a SQLSTATE, a five-character alphanumeric identifier defined in the ANSI SQL + standard. PDOStatement::errorCode only retrieves error codes + for operations performed with PDOStatement objects. - Determining which category of error occurred - + + + + &reftitle.examples; + + Retrieving a SQLSTATE code + prepare('SELECT skull FROM bones'); $err->execute(); echo "\nPDOStatement::errorCode(): "; -switch ($err->errorCode()) { - case PDO_ERR_NONE: - echo "No error!\n"; - break; - case PDO_ERR_CANT_MAP: - echo "Error: Unable to map data types between database and PHP.\n"; - break; - case PDO_ERR_SYNTAX: - echo "Error: incorrect syntax\n"; - break; - case PDO_ERR_CONSTRAINT: - echo "Error: The request would violate a constraint.\n"; - break; - case PDO_ERR_NOT_FOUND: - echo "Error: The object could not be found.\n"; - break; - case PDO_ERR_ALREADY_EXISTS: - echo "Error: The object already exists.\n"; - break; - case PDO_ERR_NOT_IMPLEMENTED: - echo "Error: The requested function is not implemented.\n"; - break; - case PDO_ERR_MISMATCH: - echo "Error: mismatch\n"; - break; - case PDO_ERR_TRUNCATED: - echo "Error: The value was truncated because the input value was longer - than the maximum column length.\n"; - break; - case PDO_ERR_DISCONNECTED: - echo "Error: The connection to the requested database has been closed.\n"; - break; -} +print $err->errorCode(); ?> ]]> - - - &example.outputs; - + + &example.outputs; + - + + + + + + &reftitle.seealso; + + + PDO::errorCode + PDO::errorInfo + PDOStatement::errorInfo + + + + + PDOStatement::errorInfo - Fetch an array of error information associated with the last operation on the statement handle + Fetch extended error information associated with the last operation on the statement handle - - Description + + &reftitle.description; arrayPDOStatement::errorInfo &warn.experimental.func; + + + + &reftitle.returnvalues; PDOStatement::errorInfo returns an array of error information about the last operation performed by this @@ -23,60 +27,76 @@ - - Element - Information - + + Element + Information + - - 0 - Generic PDO error code corresponding to one of the - PDO_ERR_* constants. - - - 1 - Driver-specific error code. - - - 2 - Driver-specific error message. - + + 0 + SQLSTATE error code (a five-character alphanumeric identifier defined + in the ANSI SQL standard). + + + 1 + Driver-specific error code. + + + 2 + Driver-specific error message. + + - Displaying errorInfo() fields for a PDO_ODBC connection to a DB2 database - + + &reftitle.examples; + + Displaying errorInfo() fields for a PDO_ODBC connection to a DB2 database + prepare('SELECT skull FROM bones'); $sth->execute(); +echo "\nPDOStatement::errorInfo():\n"; $arr = $sth->errorInfo(); -if ($arr[0] == PDO_ERR_NOT_FOUND) { - echo "Error: a requested database object does not exist.\n"; - printf("Driver-specific error code: %d\n", $arr[1]); - printf("Driver-specific message: [%s]\n", $arr[2]); -} +print_r($arr); ?> ]]> - - - &example.outputs; - + + &example.outputs; + 42S02 + [1] => -204 + [2] => [IBM][CLI Driver][DB2/LINUX] SQL0204N "DANIELS.BONES" is an undefined name. SQLSTATE=42704 +) ]]> - + + + + + + &reftitle.seealso; + + + PDO::errorCode + PDO::errorInfo + PDOStatement::errorCode + + + +