note 115484 added to language.exceptions
| From: | contact at vaibhavpandey dot com | Date: | Sun, 03 Aug 2014 08:20:00 +0000 |
| Subject: | note 115484 added to language.exceptions | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-200090@lists.php.net to get a copy of this message | ||
<?php
// Very useful in PDO wrappers
// Also this can be considered as an example
class PDOWrapper
{
private $pdo = NULL;
private $statement = NULL;
function__construct($dsn, $username = NULL, $password = NULL)
{
$this->pdo = new \PDO($dsn, $username, $password, [
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION
]);
}
function lastQuery()
{
return $this->statement;
}
function query($statement)
{
try {
return $this->pdo->query($statement);
} catch (\Exception $pdoException) {
// Do something with the error/eception
} finally {
// It helps in assignment of internal variables regardless of exception
$this->statement = $statement;
}
}
}
?>
----
Server IP: 72.52.91.14
Probable Submitter: 116.203.13.92
----
Manual Page -- http://php.net/manual/en/language.exceptions.php
Edit -- https://master.php.net/note/edit/115484
Del: integrated -- https://master.php.net/note/delete/115484/integrated
Del: useless -- https://master.php.net/note/delete/115484/useless
Del: bad code -- https://master.php.net/note/delete/115484/bad+code
Del: spam -- https://master.php.net/note/delete/115484/spam
Del: non-english -- https://master.php.net/note/delete/115484/non-english
Del: in docs -- https://master.php.net/note/delete/115484/in+docs
Del: other reasons-- https://master.php.net/note/delete/115484
Reject -- https://master.php.net/note/reject/115484
Search -- https://master.php.net/manage/user-notes.php