PDOStatement::errorCode

Fetch the SQLSTATE associated with the last operation on the statement handle

&reftitle.description; public `string` `PDOStatement::errorCode`
&reftitle.returnvalues;

Identical to `PDO::errorCode`, except that `PDOStatement::errorCode` only retrieves error codes for operations performed with PDOStatement objects.

&reftitle.examples;

### Retrieving an SQLSTATE code

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

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

&example.outputs;

    PDOStatement::errorCode(): 42S02

&reftitle.seealso;

- `PDO::errorCode`
- `PDO::errorInfo`
- `PDOStatement::errorInfo`