Advertisement
Guest User

Untitled

a guest
Jun 1st, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. <?php
  2. class cdb extends PDO{
  3. private $engine = 'mysql'; // Change to accommodate your database engine!
  4. private $host;
  5. private $user;
  6. private $pass;
  7. private $database;
  8. private $link;
  9.  
  10. static private $PDOInstance;
  11.  
  12. public function exception_handler($e){
  13. die('Uncaught Exception:'. $e->getMessage());
  14. }
  15.  
  16. public function __construct($host= false, $database= false, $user= false, $pass= false){
  17. // Set the exception handler so it catches all exceptions beforehand.
  18. set_exception_handler(Array(__CLASS__, 'exception_handler'));
  19. // Construct Connection
  20. parent::__construct($this->engine.':dbhost='.$host.';dbname='.$database, $user, $pass, Array(
  21. PDO::ATTR_PERSISTENT => TRUE));
  22. // Reset Exception Handler
  23. restore_exception_handler();
  24. }
  25. // Query
  26. public function query($statement){
  27. Return PDO::query($statement);
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement