Файл: sys/inc/db_mysqli_connect.php
Строк: 52
<?
//дополнительное mysqli соединение
class mysqli_connect {
private $db_set;
public function __construct(){
$this->file_db = $_SERVER['DOCUMENT_ROOT'] . '/sys/ini/db.ini';
if (is_file($this->file_db))
{
$this->db_set = parse_ini_file($this->file_db);
}
else
{
exit('Not settings file - /sys/ini/db.ini');
}
$this->obb = new mysqli($this->db_set['mysql_host'], $this->db_set['mysql_user'] , $this->db_set['mysql_pass'], $this->db_set['mysql_db_name']);
$this-> count = 0;
$this-> obb -> query("SET NAMES 'utf8'");
}
public function query($str)
{
return $this->q($str);
}
public function q($str)
{
$this->count++;
$strr = $this->obb->query($str);
if (!$this->obb->error) return $strr;
else
{
die('<div class="err">'. $this->obb->error .'</div>');
}
}
public function id(){
return $this->obb->insert_id;
}
public function num($sql){
return $this->q($sql)->num_rows;
}
public function obj($sql){
return $this->q($sql)->fetch_object();
}
public function ass($sql){
return $this->q($sql)->fetch_assoc();
}
public function count(){
return $this->count;
}
public function escape($sql){
return $this->real_escape_string($sql);
}
public function free_result($sql){
return $this->free_result($sql);
}
}
$sql = new mysqli_connect();