PHP PDOStatement:: errorCode Explanation
- 2021-11-14 05:11:39
- OfStack
PDOStatement::errorCode
PDOStatement:: errorCode--Gets the SQLSTATE associated with the last statement handle operation (PHP 5 > = 5.1.0, PECL pdo > = 0.1.0)
Description
Grammar
string PDOStatement::errorCode ( void )
And
PDO::errorCode()
Same, only
PDOStatement::errorCode()
Only the error code in the operation performed by PDOStatement object is retrieved.
Return value
No return value.
Instances
Retrieve 1 SQLSTATE code
<?php
/* Trigger 1 Errors -- BONES Data table does not exist */
$err = $dbh->prepare('SELECT skull FROM bones');
$err->execute();
echo "\nPDOStatement::errorCode(): ";
print $err->errorCode();
?>
The above routine outputs:
PDOStatement::errorCode(): 42S02
Summarize