<?php
{
var $db_id = false;
var $query_num = 0;
var $query_list = array(); var $mysql_error = '';
var $mysql_version = '';
var $mysql_error_num = 0;
var $mysql_extend = "MySQLi";
var $MySQL_time_taken = 0;
var $query_id = false;
function connect($db_user, $db_pass, $db_name, $db_location = 'localhost', $show_error=1)
{
$db_location = explode(":", $db_location);
if (isset($db_location[1])) {
$this->db_id = @mysqli_connect($db_location[0], $db_user, $db_pass, $db_name, $db_location[1]);
} else {
$this->db_id = @mysqli_connect($db_location[0], $db_user, $db_pass, $db_name);
}
if(!$this->db_id) {
if($show_error == 1) {
} else {
return false;
}
}
{
}
return true;
}
function query($query, $show_error=true)
{
$time_before = $this->get_real_time();
if(!$this->db_id) $this->connect(DBUSER, DBPASS, DBNAME, DBHOST);
if(!($this->query_id = mysqli_query($this->db_id, $query) )) {
if($show_error) {
$this->display_error($this->mysql_error, $this->mysql_error_num, $query); }
}
$this->MySQL_time_taken += $this->get_real_time() - $time_before;
$this->query_list[] = array( 'time' => ($this->get_real_time() - $time_before), 'query' => $query,
'num' => (count($this->query_list) + 1));
$this->query_num ++;
return $this->query_id;
}
function fetch_assoc($query_id = '')
{
if ($query_id == '') $query_id = $this->query_id;
}
function get_affected_rows()
{
}
function fetch_array($query_id = '')
{
if ($query_id == '') $query_id = $this->query_id;
}
function multi_query($query, $multi = false)
{
if(!$multi) {
$this->query($query);
$data = $this->fetch_assoc();
$this->free();
return $data;
} else {
$this->query($query);
while($row = $this->fetch_assoc()) {
$rows[] = $row;
}
$this->free();
return $rows;
}
}
function num_rows($query_id = '')
{
if ($query_id == '') $query_id = $this->query_id;
}
function insert_id()
{
}
function result($query_id = '')
{
if ($query_id == '') $query_id = $this->query_id;
return mysqli_result($query_id);
}
function get_result_fields($query_id = '') {
if ($query_id == '') $query_id = $this->query_id;
{
$fields[] = $field;
}
return $fields;
}
function real_escape_string( $source )
{
if(!$this->db_id) $this->connect(DBUSER, DBPASS, DBNAME, DBHOST);
}
function free( $query_id = '' )
{
if ($query_id == '') $query_id = $this->query_id;
}
function close()
{
}
function get_real_time()
{
return ((float)$seconds + (float)$microSeconds);
}
function display_error($error, $error_num, $query = '')
{
if($query) {
// Safify query
$query = preg_replace("/([0-9a-f]){32}/", "********************************", $query); // Hides all hashes }
$level = 0;
if ($trace[1]['function'] == "query" ) $level = 1;
if ($trace[2]['function'] == "multi_query" ) $level = 2;
$trace[$level]['file'] = str_replace("", "", $trace[$level]['file']);
echo '
<b>MySQL Error!</b><br/>
<b><b>MySQL error</b> in file: <b>'.$trace[$level]['file'].'</b> at line <b>'.$trace[$level]['line'].'</b><br/>
<b>Error Number: <b>'.$error_num.'</b><br/>
<b>The Error returned was:<br /> <b>'.$error.'</b><br/>
<b>SQL query:</b><br /><br />'.$query.'<br /><hr />';
}
}
?>