PDO::errorInfo
PDO::errorInfo - Return error information about the last statement handle operation (PHP 5 >= 5.1.0, PECL pdo >= 0.1.0)
Description
Syntax
public array PDO::errorInfo ( void )
Return Value
Returns an array containing a description of the error information from the last database operation.
The array contents are as follows:
| Element | Information |
|---|---|
| 0 | SQLSTATE error code (an identifier of 5 letters or digits defined in the ANSI SQL standard). |
| 1 | Error code |
| 2 | Error message |
**Note:** If the database handle has not performed an operation, NULL is returned.
Example
Display the error information from errorInfo() for a PDO_ODBC connection to a DB2 database
prepare('bogus sql');
if (!$stmt) {
echo "\nPDO::errorInfo():\n";
print_r($dbh->errorInfo());
}
?>
The above example will output:
PDO::errorInfo():
Array
(
[0] => HY000
[1] => 1
[2] => near "bogus": syntax error
)
PHP PDO Reference Manual