note 59356 deleted from function.pdo-errorcode by nlopess
| From: | nlopess@php.net | Date: | Sun, 04 Dec 2005 12:43:37 +0000 |
| Subject: | note 59356 deleted from function.pdo-errorcode by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-99551@lists.php.net to get a copy of this message | ||
Note Submitter: Matthias Leuffen
----
Hi,
List containing all SQL-92 SQLSTATE Return Codes:
http://www.unix.org.ua/orelly/java-ent/jenut/ch08_06.htm
Use the following Code to let PDO throw Exceptions (PDOException) on Error.
<?PHP
$pdo = new PDO (whatever);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
try {
$pdo->exec ("QUERY WITH SYNTAX ERROR");
} catch (PDOException $e) {
if ($e->getCode == '2A000')
echo "Syntax Error: ".$e->getMessage();
}
?>
Bye,
Matthias