mysqli = @mysqli_connect($server, $user, $password); if (!$this->mysqli) { throw new Exception(mysqli_connect_error()); } } public function __destruct() { if (!empty($this->mysqli)) { @$this->mysqli->close(); $this->mysqli = null; } } public function list_dbs() { $db_list = $this->mysqli->query("SHOW DATABASES"); $databases = array(); if ($db_list) { while ($row = $db_list->fetch_row()) { $databases[$row[0]] = 1; } } return $databases; } }