<?php
    class Action_log{
        
        var $db = null;
        public $dir_name = null;
        public function Save($query){
            if (!$this->db) $this->set_DB_connect();
            $this->db->query($query);
            $this->unset_DB_connect();   
        }
        
        /*private function Log_open(){
            $lfile = $this->log_file;
            $this->fp = fopen($lfile,"a+") or exit("Невозможно открыть $lfile!");
            //fclose($lfile);
        } */
        
        //function for getting need variables if we have only id
        public function get_Info($query){
            if (!$this->db) $this->set_DB_connect();
            $result=$this->db->query($query);
            $row=$result->fetch_assoc();
            return $row;
        }
        
        private function set_DB_connect(){
            require($this->dir_name."settings.php");
            $this->db = new mysqli ($EDB_HOST,$EDB_USER,$EDB_PASS,$EDB_NAME);
            $this->db->query("SET CHARSET SET utf8");
            $this->db->query("SET NAMES 'utf8'");
            if (mysqli_connect_errno()) {
                exit ("Ошибка подключения к БД" );
            }
        }
        public function unset_DB_connect(){
            $this->db->close();
        }
    }
?>