array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'uk', ), 'this' => array ( 0 => 'pdostatement.errorcode.php', 1 => 'PDOStatement::errorCode', 2 => 'Fetch the SQLSTATE associated with the last operation on the statement handle', ), 'up' => array ( 0 => 'class.pdostatement.php', 1 => 'PDOStatement', ), 'prev' => array ( 0 => 'pdostatement.debugdumpparams.php', 1 => 'PDOStatement::debugDumpParams', ), 'next' => array ( 0 => 'pdostatement.errorinfo.php', 1 => 'PDOStatement::errorInfo', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/pdo/pdostatement/errorcode.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>
(PHP 5 >= 5.1.0, PHP 7, PHP 8, PECL pdo >= 0.1.0)
PDOStatement::errorCode — Fetch the SQLSTATE associated with the last operation on the statement handle
У цієї функції немає параметрів.
Identical to PDO::errorCode(), except that PDOStatement::errorCode() only retrieves error codes for operations performed with PDOStatement objects.
Приклад #1 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();
?>
Поданий вище приклад виведе:
PDOStatement::errorCode(): 42S02