note 59357 modified in pdo.errorcode by googleguy
| From: | googleguy@php.net | Date: | Fri, 21 Sep 2012 17:50:15 +0000 |
| Subject: | note 59357 modified in pdo.errorcode by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-190952@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
--was--
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
http://php.net/manual/en/pdo.errorcode.php