PHP: PDOStatement->errorCode() - Manual

downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

PDOStatement->errorInfo() PDOStatement->columnCount()

Last updated: Sat, 27 Jan 2007

view this page in

# PDOStatement->errorCode()

(no version information, might be only in CVS)

PDOStatement->errorCode() -- Fetch the SQLSTATE associated with the last operation on the statement handle

## Описание

class PDOStatement {
string errorCode ( void )
}

## Возвращаемые значения

Identical to PDO->errorCode(), except that PDOStatement->errorCode() only retrieves error codes for operations performed with PDOStatement objects.

## Примеры

Пример 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();
?>`

Результат выполнения данного примера:

    PDOStatement::errorCode(): 42S02

## Смотрите также

PDO->errorCode()
PDO->errorInfo()
PDOStatement->errorInfo()

add a note User Contributed Notes
PDOStatement->errorCode()
vaclav dot sir at gmail dot com
05-Jun-2006 08:59
`Statement's errorCode() returns an empty string before execution, and '00000' (five zeros) after a sucessfull execution:
<?php
$stmt = $pdo->prepare($query);
assert($stmt->errorCode === '');
$stmt->execute();
assert($stmt->errorCode === '00000');
?>`
add a note
PDOStatement->errorInfo() PDOStatement->columnCount()

Last updated: Sat, 27 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 10:36:09 2007 PST