public function open()
{
$this->close();
$this->conn = mysqli_connect($this->host, $this->username, $this->password, $this->dbname);
if (!$this->conn) {
throw new SwarmException("Connection to {$this->host} failed.\nMySQL Error " . $this->lastErrNo() . ': ' . $this->lastErrMsg());
}
if (method_exists($this->conn, 'set_charset')) {
if (!$this->conn->set_charset('binary')) {
throw new SwarmException('Error setting character set on MySQL connection');
}
}
$this->isOpen = true;
return $this;
}