Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class db {
- static private $instance;
- private $host = 'localhost';
- private $user = 'username';
- private $password = 'password';
- private $db = 'database';
- private $mysqli;
- static public function getInstance() {
- if (!isset(self::$instance)) {
- self::$instance = new self();
- }
- return self::$instance;
- }
- public function __construct() {
- $this->mysqli = new mysqli($this->host,$this->user,$this->password,$this->db);
- if ($this->mysqli->connect_errno()) {
- printf("Error %s\n".$this->mysqli->connect_errno());
- exit;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement