class MySQL_class {
public $dblink = null;
public $result = array ();
public $count_query = 0;
public $error_MySQL = null;
public $query_sql = array();
public function __construct() {
$this->dblink = @mysql_pconnect ( db_host, db_username, db_password );
if ($this->dblink && mysql_select_db ( db_database )) {
if (version_compare ( mysql_get_server_info (), '4.1', ">=" ))
mysql_query ( '/*!40101 SET NAMES "utf-8" */' );
mysql_query ( 'set character_set_connection=utf8' );
mysql_query ( 'set character_set_client=utf8' );
mysql_query ( 'set character_set_results=utf8' );
} else {
die ( 'Ошибка при подключении к базе данных, эта ошибка может быть вызвана не правильными данными для подключения к базе данных, или на данный момент база данных не работает. Приносим свои извинения.');
}
}
public function query($sql_query, $id_query = 'main') {
if(is_array($sql_query)) {
foreach ($sql_query as $sql_query_id) {
$result = mysql_query ( $sql_query_id, $this->dblink );
}
return true;
}
$result = mysql_query ( $sql_query, $this->dblink );
if (!$result) {
if (debug) {
$this -> error_MySQL .= '<pre><br>' . mysql_error () . '<br>' . $sql_query . '<br></pre>';
}
return false;
} else {
$this -> query_sql [] = $sql_query;
$this->result [$id_query] = $result;
$this -> count_query = $this -> count_query + 1;
return true;
}
}
function fetch_object($id_query = 'main') {
if ($this->result [$id_query]) {
$this->dbrow = mysql_fetch_object ($this->result[$id_query]);
return $this->dbrow;
}
}
}