Переделал, работавший на MYSQL, класс подключения, но увы ?
$db = new Dbaccess;
$db_result = $db->connect ( $db_host, $db_user, $db_pass, $db_name );
$db->query ('SET names "utf8"');
if ( !$db_result )
{
printf("Невозможно подключиться к базе данных. Код ошибки: %s\n", mysqli_connect_error());
exit;
}
////////////////////////////// Dbaccess /////////////////////////
class Dbaccess
{
var $q_array = array();
var $db_id;
var $query;
var $counter = 0;
var $timecounter = 0;
var $query_res;
// $db->connect ("host", "login", "password", "database");
function connect ($host, $login, $password, $db)
{
$this->host = $host;
$this->login = $login;
$this->password = $password;
$this->db = $db;
$this->db_id = mysqli_connect($this->host, $this->login, $this->password);
if ($this->db_id)
{
$db_select = mysqli_select_db($this->db);
if (!$db_select)
{
mysqli_close($this->db_id);
$this->db_id = $db_select;
}
else
return $this->db_id;
}
else
return false;
}
// Close database connection and free results memory
function close()
{
if($this->db_id)
{
if($this->query)
{
mysqli_free_result($this->query);
}
$result = mysqli_close($this->db_id);
return $result;
}
else
{
return false;
}
}
// Run sql query
function query ($query)
{
if($query)
{
$this->query = mysqli_query($query);
return $this->query;
}
else
{
return false;
}
}
// $db->numrows($resource);
function numrows ($query_id)
{
if($query_id)
{
$result = mysqli_numrows($query_id);
return $result;
}
else
{
return false;
}
}
// $db->fetcharray($resource);
function fetcharray ($query_id)
{
if(!$query_id)
{
$query_id = $this->query_res;
}
if($query_id)
{
$this->q_array[$query_id] = mysqli_fetch_assoc($query_id);
return $this->q_array[$query_id];
}
else
{
return false;
}
}
// $db->freeresult($resource);
function freeresult ($query_id)
{
if ( $query_id )
{
unset($this->array[$query_id]);
mysqli_free_result($query_id);
return true;
}
else
{
return false;
}
}
}
Подправте, пожалуйста