代码语言:javascript复制
class Db {
private static $instance;
public $handle;
Private function __construct($host,$username,$password,$dbname) {
$this->handle=NULL;
$this->getcon($host,$username,$password,$dbname);
}
public static function getBb() {
self::$instance=new Db();
return self::$instance;
}
private function getcon($host,$username,$password,$dbname) {
if($this->handle!=NULL){
return true;
}
$this->handle=mysqli_connect($host,$username,$password,$dbname);
}
}