access = $access;
$this->accesslookup();
if (!$this->error) {
$this->connect();
}
}
//Checks configuration for appropriate permissions
function accessLookup() {
$this->host = get_cfg_var('mysql.'.$this->access.'.host');
$this->user = get_cfg_var('mysql.'.$this->access.'.user');
$this->pass = get_cfg_var('mysql.'.$this->access.'.pass');
if ($this->host == null || $this->user == null || $this->pass == null) {
echo 'Sorry, there has been an issue with your request. Please try again later.
Error DB1.';
error_log('Error retrieving database configuration variable(s) for '. $this->access, 0);
$this->error = true;
}
}
//Opens connection with Database
function connect() {
$this->Conn = @mysql_connect($this->host, $this->user, $this->pass);
if (!$this->Conn) {
die('Sorry, there has been an issue with your request. Please try again later.
Error DB2.');
error_log('Error connecting to database server using access level: '. $this->access, 0);
} else if (!mysql_select_db('yooia', $this->Conn)) {
die('Sorry, there has been an issue with your request. Please try again later.
Error DB3.');
error_log('Error connect to database Yooia');
}
}
//Closes connection with Database
function close() {
if ($this->Conn) {
return mysql_close($this->Conn);
}
}
//Sends Query to Database
function &query($sql) {
$sql = preg_replace('/\s\s+/', ' ', $sql);
$result = mysql_query($sql, $this->Conn);
if (!$result) {
die('Sorry, there has been an issue with your request. Please try again later.
Error DB4.');
error_log('Error receiving data using the following query: '.$sql);
}
$this->close();
return $result;
}
}
?>