public function Open($database = null, $server = null, $username = null, $password = null, $charset = null, $pcon = false)
{
$this->ResetError();
// Use defaults?
if ($database !== null) {
$this->db_dbname = $database;
}
if ($server !== null) {
$this->db_host = $server;
}
if ($username !== null) {
$this->db_user = $username;
}
if ($password !== null) {
$this->db_pass = $password;
}
if ($charset !== null) {
$this->db_charset = $charset;
}
if (is_bool($pcon)) {
$this->db_pcon = $pcon;
}
$this->active_row = -1;
// Open persistent or normal connection
if ($pcon) {
$this->mysql_link = @mysqli_pconnect('p:' . $this->db_host, $this->db_user, $this->db_pass);
} else {
$this->mysql_link = @mysqli_connect($this->db_host, $this->db_user, $this->db_pass);
}
// Connect to mysql server failed?
if (!$this->IsConnected()) {
$this->SetError();
return false;
} else {
// Select a database (if specified)
if (strlen($this->db_dbname) > 0) {
if (strlen($this->db_charset) == 0) {
if (!$this->SelectDatabase($this->db_dbname)) {
return false;
} else {
return true;
}
} else {
if (!$this->SelectDatabase($this->db_dbname, $this->db_charset)) {
return false;
} else {
return true;
}
}
} else {
return true;
}
}
}