note 106190 deleted from pdo.error-handling by danbrown
| From: | danbrown@php.net | Date: | Tue, 18 Oct 2011 14:47:27 +0000 |
| Subject: | note 106190 deleted from pdo.error-handling by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-183972@lists.php.net to get a copy of this message | ||
Note Submitter: iowamiker at hotmail dot com
----
When using
<?php
$dbconn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
?>
to enable exception handling, PDO will sometimes emit a warning, even though PDO::ERRMODE_EXCEPTION.
In the following example, the statement $stmt->execute($sql) will emit a PDO Warning message:
<?php
$dbconn = new PDO(...);
$dbconn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$myvalue="example";
$sql = "SELECT * FROM mytable WHERE mycol=:mycol";
$stmt = $dbconn->prepare($sql);
$res=$stmt->bindParam(':mycol, $myvalue);
$b = $stmt->execute($sql);
?>