Files
BiveEngine/engine/Main/trait.database.php
2025-12-24 19:19:01 +03:00

34 lines
949 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// Работа с базой данных
defined('ROOT_DIR') || exit;
require ENGINE_DIR . SLASH . "class.database.php";
trait Database {
private DB $db_class;
public function db_touch()
{
$this->db_class = new DB(DB_HOST, DB_NAME, DB_USER, DB_PASS);
$this->db_class->connect();
}
// Запрос на получение информации из базы
public function db_query($query, $params = array(), $new = false)
{
$ls_key = $query . json_encode($params);
if(!$new && $this->ls_has_key($ls_key))
return $this->ls_get_key($ls_key);
$result = $this->db_class->query($query, $params);
$this->ls_set_key($ls_key, $result);
return $result;
}
// Запрос на сохранение данных в базу
public function db_insert($query, $params)
{
return $this->db_class->insert($query, $params);
}
}