Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.60 KB | None | 0 0
  1. <?php
  2. class db {
  3.     static private $instance;
  4.     private $host = 'host';
  5.     private $user = 'username';
  6.     private $password = 'password';
  7.     private $db = 'database';
  8.     private $mysql;
  9.     static public function getInstance() {
  10.         if (!isset(self::$instance)) {
  11.             self::$instance = new self();
  12.         }
  13.         return self::$instance;
  14.     }
  15.     public function __construct() {
  16.         $mysql = mysql_connect($this->host, $this->user, $this->password);
  17.         if (!$mysql) {
  18.             die('Could not connect: ' . mysql_error());
  19.         }
  20.         if (!mysql_select_db($this->db,$mysql)) {
  21.             die('Could not connect: ' . mysql_error());
  22.         }
  23.     }
  24. }
  25.  
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement