PDOStatement::errorCode

(no version information, might be only in CVS)

PDOStatement::errorCode --  Fetch the SQLSTATE associated with the last operation on the statement handle

Descrição

int PDOStatement::errorCode ( void )

Atenção

Esta função é EXPERIMENTAL. Isso quer dizer que o comportamento desta função e seu nome, incluindo TUDO o que está documentado aqui pode mudar em futuras versões do PHP, SEM QUALQUER NOTIFICAÇÃO. Esteja avisado, e use esta função por sua própria conta e risco.

Valores Retornados

Returns a SQLSTATE, a five-character alphanumeric identifier defined in the ANSI SQL standard. PDOStatement::errorCode() only retrieves error codes for operations performed with PDOStatement objects.

Exemplos

Exemplo 1. Retrieving a 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();
?>

O exemplo acima irá imprimir:

PDOStatement::errorCode(): 42S02

Veja também

PDO::errorCode()
PDO::errorInfo()
PDOStatement::errorInfo()