Advertisement
Guest User

Untitled

a guest
Feb 12th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. class DB
  2. {
  3.  
  4.     private $DB_host = "stc885.csesalford.com";
  5.     private $DB_user = "stc885";
  6.     private $DB_pass = "iv9bBshl2";
  7.     private $DB_name = "stc885";
  8.     private $DB_con;
  9.     private static $instance = null;
  10.  
  11.     private function __construct()
  12.     {
  13.         //try {
  14.             $this->DB_con = new PDO("mysql:host={$this->DB_host};dbname={$this->DB_name}", $this->DB_user, $this->DB_pass);
  15.             $this->DB_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  16.         //} catch (PDOException $e) {
  17.         //    echo $e->getMessage();
  18.         //}
  19.  
  20.     }
  21.  
  22.     // The object is created from within the class itself
  23.     // only if the class has no instance.
  24.     public static function getInstance()
  25.     {
  26.         if (self::$instance == null)
  27.         {
  28.             self::$instance = new DB();
  29.         }
  30.  
  31.         return self::$instance;
  32.     }
  33.  
  34.     public function getConnection()
  35.     {
  36.         return $this->DB_con;
  37.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement