Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.55 KB | None | 0 0
  1. class db {
  2.     static private $instance;
  3.     private $host = 'localhost';
  4.     private $user = 'username';
  5.     private $password = 'password';
  6.     private $db = 'database';
  7.     private $mysqli;
  8.     static public function getInstance() {
  9.         if (!isset(self::$instance)) {
  10.             self::$instance = new self();
  11.         }
  12.         return self::$instance;
  13.     }
  14.     public function __construct() {
  15.         $this->mysqli = new mysqli($this->host,$this->user,$this->password,$this->db);
  16.         if ($this->mysqli->connect_errno()) {
  17.             printf("Error %s\n".$this->mysqli->connect_errno());
  18.             exit;
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement