Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class cdb extends PDO{
- private $engine = 'mysql'; // Change to accommodate your database engine!
- private $host;
- private $user;
- private $pass;
- private $database;
- private $link;
- static private $PDOInstance;
- public function exception_handler($e){
- die('Uncaught Exception:'. $e->getMessage());
- }
- public function __construct($host= false, $database= false, $user= false, $pass= false){
- // Set the exception handler so it catches all exceptions beforehand.
- set_exception_handler(Array(__CLASS__, 'exception_handler'));
- // Construct Connection
- parent::__construct($this->engine.':dbhost='.$host.';dbname='.$database, $user, $pass, Array(
- PDO::ATTR_PERSISTENT => TRUE));
- // Reset Exception Handler
- restore_exception_handler();
- }
- // Query
- public function query($statement){
- Return PDO::query($statement);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement