Easy Tutorial
❮ Php Remove Sapi Php Pdo Error Handling ❯

PDOStatement::errorCode

PHP PDO Reference Manual

PDOStatement::errorCode — Retrieves 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 )

Similar to PDO::errorCode(), but PDOStatement::errorCode() retrieves only the error code from operations performed on the PDOStatement object.


Return Value

No return value.


Examples

Retrieving an SQLSTATE Code

<?php
/* Trigger an error -- the BONES table does not exist */
$err = $dbh->prepare('SELECT skull FROM bones');
$err->execute();

echo "\nPDOStatement::errorCode(): ";
print $err->errorCode();
?>

The above example will output:

PDOStatement::errorCode(): 42S02

PHP PDO Reference Manual

❮ Php Remove Sapi Php Pdo Error Handling ❯