Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Database extends mysqli
- {
- private static
- $instance = null;
- private
- $host = DB_HOST,
- $user = DB_USER,
- $password = DB_PASSWORD,
- $database = DB_DATABASE;
- private function __construct()
- {
- @parent::__construct(
- $this->host,
- $this->user,
- $this->password,
- $this->database
- );
- if (mysqli_connect_errno())
- {
- throw new Exception(
- mysqli_connect_error(),
- mysqli_connect_errno()
- );
- }
- }
- public static function get_instance()
- {
- if (!isset($instance)) {
- $c = __CLASS__;
- $instance = new $c;
- }
- return $instance;
- }
- public function __clone()
- {
- throw new Exception("Cannot clone ".__CLASS__." class");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement