note 111850 added to pdo.connections
| From: | TerrenceLP | Date: | Thu, 04 Apr 2013 13:41:46 +0000 |
| Subject: | note 111850 added to pdo.connections | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-194337@lists.php.net to get a copy of this message | ||
Correction to post #1 - there is a syntax error on like 6 that has been corrected below.
<?php
class SafePDO extends PDO {
public static function exception_handler($exception) {
// Output the exception details
print('Uncaught exception: '. $exception->getMessage());
}
public function __construct($dsn, $username='webaccess',
$password='Terrence1', $driver_options=array(
PDO::ATTR_PERSISTENT => true
)) {
// Temporarily change the PHP exception handler while we . . .
set_exception_handler(array(__CLASS__, 'exception_handler'));
// . . . create a PDO object
parent::__construct($dsn, $username, $password, $driver_options);
// Change the exception handler back to whatever it was before
restore_exception_handler();
}
}
// Connect to the database with defined constants
$dbh = new SafePDO(PDO_DSN, PDO_USER, PDO_PASSWORD);
?>
----
Server IP: 69.147.83.199
Probable Submitter: 166.147.121.168
----
Manual Page -- http://php.net/manual/en/pdo.connections.php
Edit -- https://master.php.net/note/edit/111850
Del: integrated -- https://master.php.net/note/delete/111850/integrated
Del: useless -- https://master.php.net/note/delete/111850/useless
Del: bad code -- https://master.php.net/note/delete/111850/bad+code
Del: spam -- https://master.php.net/note/delete/111850/spam
Del: non-english -- https://master.php.net/note/delete/111850/non-english
Del: in docs -- https://master.php.net/note/delete/111850/in+docs
Del: other reasons-- https://master.php.net/note/delete/111850
Reject -- https://master.php.net/note/reject/111850
Search -- https://master.php.net/manage/user-notes.php