Pdo Errorinfo
# PDO::errorInfo
[PHP PDO Reference Manual](#)
PDO::errorCode β Returns error information for the last database operation (PHP 5 >= 5.1.0, PECL pdo >= 0.1.0)
* * *
## Description
### Syntax
public array PDO::errorInfo ( void )
* * *
## Return Value
Returns an array containing error information for the last database operation.
The array contents are as follows:
| Element | Information |
| --- | --- |
| 0 | SQLSTATE error code (a 5-character alphanumeric identifier defined in the ANSI SQL standard). |
| 1 | Driver-specific error code. |
| 2 | Driver-specific error message. |
* * *
**Note:** If the database handle has not been used for any operations, it returns NULL.
## Example
### Displaying 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( => HY000 => 1 => near "bogus": syntax error )
* * PHP PDO Reference Manual](#)
YouTip