PDOStatement::errorCode
PDOStatement::errorCode — Get the SQLSTATE associated with the last operation on the statement handle (PHP 5 >= 5.1.0, PECL pdo >= 0.1.0)
Description
Syntax
string PDOStatement::errorCode ( void )
Same as PDO::errorCode(), except that PDOStatement::errorCode() only fetches error codes for operations performed on PDOStatement objects.
Return Values
No return value.
Examples
Fetch a SQLSTATE code
<?php
/* 引发一个错误 -- BONES 数据表不存在 */
$err = $dbh->prepare('SELECT skull FROM bones');
$err->execute();
echo "\nPDOStatement::errorCode(): ";
print $err->errorCode();
?>
The above example will output:
PDOStatement::errorCode(): 42S02
Other Extensions
PHP PDO Reference Manual