php class SqlInc extends mysqli private db_host private db_login priva

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
class SqlInc extends mysqli{
private $db_host ='';
private $db_login ='';
private $db_password='';
private $db_table ='';
private $db_encoding='utf8';
private static $instance;
public
function __construct(){
//Если подключения нет то создаём ево
if(is_null(self::$instance)){
self::$instance = parent::__construct($this->db_host, $this->db_login, $this->db_password, $this->db_table);
if(mysqli_connect_error()){
die('Не удалось подключится к mysql');
}
parent::set_charset($this->db_encoding);
}else{
return self::$instance;
}
}
public
function __destruct(){
return parent::close();
}
}
?>