Example #1
0
 /**
  * Constructor prepare DB
  *
  * @access public
  *
  * @param array $params configuration params
  *
  * @result void
  * @throws Exception
  */
 public function __construct(array $params = [])
 {
     parent::__construct($params);
     $this->tableName = !empty($params['table']) ? $params['table'] : 'logs';
     $this->db = (new Injector())->getDriver();
     if (!$this->db->tableExists($this->tableName)) {
         $this->db->createTable($this->tableName, array('`id` INT AUTO_INCREMENT', '`level` VARCHAR(20) NOT NULL', '`message` TEXT NOT NULL', '`date_create` INT NOT NULL', 'PRIMARY KEY(id)'), 'ENGINE=InnoDB DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci');
     }
 }