Latest web development tutorials

PDOStatement :: errorInfo

PHP PDO Reference Manual PHP PDO Reference Manual

PDOStatement :: errorInfo - Get a handle to keep up with a statement related to the operation of extended error information (PHP 5> = 5.1.0, PECL pdo> = 0.1.0)


Explanation

grammar

array PDOStatement::errorInfo ( void )

PDOStatement :: errorInfo () returns an array on a statement handle to perform operations on the error message. The array contains the following fields:

element information
0 SQLSTATE error code (a standard in the ANSI SQL identifiers defined by the five letters or numbers).
1 Specific drive error code.
2 Specific drive error information.

Examples

Connect to errorInfo PDO_ODBC DB2 database connection () fields

<?php
/* 激发一个错误 --  BONES 数据表不存在 */
$sth = $dbh->prepare('SELECT skull FROM bones');
$sth->execute();

echo "\nPDOStatement::errorInfo():\n";
$arr = $sth->errorInfo();
print_r($arr);
?>
<pre>
PDOStatement::errorCode(): 42S02

The above example will output:

PDOStatement::errorInfo():
Array
(
    [0] => 42S02
    [1] => -204
    [2] => [IBM][CLI Driver][DB2/LINUX] SQL0204N  "DANIELS.BONES" is an undefined name.  SQLSTATE=42704
)

PHP PDO Reference Manual PHP PDO Reference Manual