PDOStatement::errorInfo — Get extended error information related to the last statement handle operation (PHP 5 >= 5.1.0, PECL pdo >= 0.1.0)
array PDOStatement::errorInfo ( void )
PDOStatement::errorInfo() Returns an array of error information about the last operation performed by the statement handle. The array contains the following fields:
element | information |
---|---|
0 | SQLSTATE error code (a 5-letter or numeric identifier defined in the ANSI SQL standard). |
1 | Specific driver error code. |
2 | Specific driver error information. |
<?php/* trigger an error -- BONES data table does not exist*/$sth = $dbh->prepare('SELECT FROM skull bones');$sth->execute();echo "nPDOStatement::errorInfo( ):n";$arr = $sth->errorInfo();print_r($arr);?><pre>PDOStatement::errorCode(): 42S02
The above routine will output:
PDOStatement::errorInfo():Array( [0] => 42S02 [1] => -204 [2] => [IBM][CLI Driver][DB2/LINUX] SQL0204N "DANIELS.BONES" is an undefined name. SQLSTATE=42704)