Файл: public_html/inc/mysqli.php
Строк: 55
<?php
if (!defined('BASE_DIR')) { exit(header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true)); }
class MySQL
{
private static $instance;
public $db_count = 0;
public $db_link;
private function __construct()
{
$this->db_link = new mysqli(BD_HOST, BD_USER, BD_PASS, BD_NAME, 3306);
if($this->db_link->connect_error)
{
exit();
}
$this->db_link->set_charset("utf8");
}
public static function getInstance()
{
if (self::$instance === null)
{
self::$instance = new self();
}
return self::$instance;
}
public function query($sql)
{
$query = $this->db_link->query($sql);
if ($this->db_link->error)
{
exit($this->db_link->error);
}
return $query;
}
private function fetch_assoc($result)
{
return $result->fetch_assoc();
}
public function fetch_assoc_all($result)
{
$data = array();
while($row = $result->fetch_assoc())
{
$data[] = $row;
}
return $data;
}
public function insert_id()
{
return $this->db_link->insert_id;
}
private function num_rows($result)
{
return $result->num_rows;
}
public function __destruct()
{
$this->db_link->close();
}
}