Código (php-brief) [Seleccionar]
class DBHandler {
private $link;
private $db_name;
// On instance created connect to host
// For installation, database name is null
public function __construct($db_name = NULL) {
$this->db_name = $db_name;
$this->link = $this->connection($db_name);
}
private function connection() {
$this->link = @new mysqli(DB_HOST, DB_USER, DB_PASSWORD, $this->db_name);
if($this->link)
return $this->link;
else
die('Couldnt connect to db: ' . $this->link->connect_error);
}
private function disconnect() {
$this->link->close();
}
public function __destruct() {
// Check if connection was established
if($this->link != NULL)
$this->disconnect();
}
}
Recibo:
CitarPHP Warning: mysqli::close(): Couldn't fetch mysqli in includes/DBHandler.php on line 24
o sea en la linea:
Código (php-brief) [Seleccionar]
$this->connection->close();