PDO :: errorCode
PDO :: errorCode - Get a handle on the database associated with the operation of SQLSTATE (PHP 5> = 5.1.0, PECL pdo> = 0.1.0)
Explanation
grammar
mixed PDO::errorCode ( void )
return value
Returns a SQLSTATE, an ANSI SQL standard identifiers defined by the five letters or numbers. Briefly, a SQLSTATE value by subclasses class value behind the front two characters and three-character composition.
If the database handle is not operated, it returns NULL.
Examples
Get a SQLSTATE code
/* 引发一个错误 -- BONES 数据表不存在 */ $dbh->exec("INSERT INTO bones(skull) VALUES ('lucy')"); echo "\nPDO::errorCode(): "; print $dbh->errorCode(); ?>
The above example will output:
PDO::errorCode(): 42S02