YouTip LogoYouTip

Pdo Errorcode

# PDO::errorCode [![Image 3: PHP PDO Reference](#)PHP PDO Reference](#) PDO::errorCode β€” Get the SQLSTATE associated with the last operation on the database handle (PHP 5 >= 5.1.0, PECL pdo >= 0.1.0) * * * ## Description ### Syntax mixed PDO::errorCode ( void ) * * * ## Return Value Returns a SQLSTATE, a five-character alphanumeric identifier defined in the ANSI SQL standard. Briefly, a SQLSTATE consists of a two-character class value followed by a three-character subclass value. If the database handle has not performed any operations, returns NULL. * * * ## Example ### Get a SQLSTATE code /* Trigger an error -- the BONES table does not exist */ $dbh->exec("INSERT INTO bones(skull) VALUES ('lucy')"); echo "nPDO::errorCode(): ";print $dbh->errorCode();?> The above example will output: PDO::errorCode(): 42S02 * * PHP PDO Reference](#)
← Pdo ErrorinfoPdo Construct β†’