daily pastebin goal
59%
SHARE
TWEET

Untitled

a guest Mar 26th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. class Database {
  4.  
  5.     private $db_name;
  6.     private $db_user;
  7.     private $db_pass;
  8.     private $db_host;
  9.     private $pdo;
  10.  
  11.     public function __construct($db_name = 'blog', $db_user = 'root', $db_pass = 'root', $db_host = 'localhost')
  12.     {
  13.         $this->db_name = $db_name;
  14.         $this->db_user = $db_user;
  15.         $this->db_pass = $db_pass;
  16.         $this->db_host = $db_host;
  17.     }
  18.  
  19.     private function getPDO(){
  20.         if($this->pdo === NULL){
  21.             $pdo = new PDO ("mysql:dbname={$this->db_name};host={$this->db_host}", "{$this->db_user}", "{$this->db_pass}");
  22.             $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  23.             $this->pdo = $pdo;
  24.         }
  25.         return $this->pdo;
  26.     }
  27. }
  28.  
  29. ?>
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