Вход Регистрация
Файл: sys/inc/db_mysqli_connect.php
Строк: 52
<?

//дополнительное mysqli соединение
class mysqli_connect
{
    public 
$time_query,/* необязательно, это не время запроса, а время соединения*/ 
           
$is_connect false/* можно использовать класс в инсталяторе */
           
$err_connect false/* можно использовать класс в инсталяторе */
           
$err_db false,/* необязательно */
           
$db
           private 
$db_conf;
    function 
__construct()
    {
        
$this->file_db $_SERVER['DOCUMENT_ROOT'] . '/sys/ini/db.ini';
        if (
is_file($this->file_db))
        {
            
$this->db_conf parse_ini_file($this->file_db);
        } else
            exit(
'Not settings file - /sys/ini/db.ini!');// необязательно
        
if (extension_loaded('mysqli'))
        {
            
$time_start microtime(true);
            
$this->db mysqli_connect($this->db_conf['mysql_host'], $this->db_conf['mysql_user'],
                
$this->db_conf['mysql_pass'], $this->db_conf['mysql_db_name']);
            if (!
$this->db)
            {
                
$this->err_connect true;
            } elseif (!
mysqli_select_db($this->db$this->db_conf['mysql_db_name']))// необязательно
                
$this->err_db true;
            else
                
$this->is_connect true;
            
$this->time_query += round((microtime(true) - $time_start), 4);
            return 
$this->db;
            
mysqli_close($this->db);// необязательно
        

        else
        {
            
$time_start microtime(true);
            
$this->db mysql_connect($this->db_conf['mysql_host'], $this->db_conf['mysql_user'],
                
$this->db_conf['mysql_pass']);
            
mysql_select_db($this->db_conf['mysql_db_name']);
            if (!
$this->db)
            {
                
$this->err_connect true;
            }
            else
            
$this->is_connect true;
            
$this->time_query += round((microtime(true) - $time_start), 4);
            return 
$this->db;
            
//mysql_close($db);
        
}
    }

}

$link = new mysqli_connect;
Онлайн: 2
Реклама