daily pastebin goal
46%
SHARE
TWEET

Untitled

a guest Apr 21st, 2018 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.     use PDO;
  3.     Class SafePDO extends PDO {
  4.         private $server = "";
  5.         private $username = "";
  6.         private $pass = "";
  7.         private $database = "";
  8.         public static function exception_handler($exception) {
  9.             die('Uncaught exception: ' . $exception->getMessage());
  10.         }
  11.         public function __construct() {
  12.             // Temporarily change the PHP exception handler while we . . .
  13.             set_exception_handler(array(__CLASS__, 'exception_handler'));
  14.             // . . . create a PDO object
  15.             $dsn = 'mysql:host=' . $this->server . ';dbname=' . $this->database;
  16.             parent::__construct($dsn, $this->username, $this->pass);
  17.             // Change the exception handler back to whatever it was before
  18.             restore_exception_handler();
  19.         }
  20.     }
  21. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top