note 59357 added to function.pdo-errorcode
| From: | MatthiasLeuffen at osu1 dot php dot net | Date: | Sun, 04 Dec 2005 12:36:18 +0000 |
| Subject: | note 59357 added to function.pdo-errorcode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-99550@lists.php.net to get a copy of this message | ||
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
----
Manual Page -- http://www.php.net/manual/en/function.pdo-errorcode.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+59357
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59357&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59357&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59357&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59357&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59357&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59357&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59357&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+59357&report=yes
Search -- http://master.php.net/manage/user-notes.php