aboutsummaryrefslogtreecommitdiff
path: root/lib/config.php
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2024-01-31 06:11:00 +0300
committerEvgeny Zinoviev <me@ch1p.io>2024-01-31 20:45:40 +0300
commitc0dc531ebefd8912819f3b6c8bda1fed3c7e750c (patch)
tree2c75aa9df182260aef09faf4befd81a4c2b9c5e2 /lib/config.php
parent48d688cdf7f9eae1bf11b8a6f0e5b98687c604cb (diff)
make it simple, but not simpler
Diffstat (limited to 'lib/config.php')
-rw-r--r--lib/config.php46
1 files changed, 0 insertions, 46 deletions
diff --git a/lib/config.php b/lib/config.php
deleted file mode 100644
index bb7e5ca..0000000
--- a/lib/config.php
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-
-class config {
-
- public static function get(string $key) {
- $db = getDb();
- $q = $db->query("SELECT value FROM config WHERE name=?", $key);
- if (!$db->numRows($q))
- return null;
- return $db->result($q);
- }
-
- public static function mget($keys) {
- $map = [];
- foreach ($keys as $key) {
- $map[$key] = null;
- }
-
- $db = getDb();
- $keys = array_map(fn($s) => $db->escape($s), $keys);
-
- $q = $db->query("SELECT * FROM config WHERE name IN('".implode("','", $keys)."')");
- while ($row = $db->fetch($q))
- $map[$row['name']] = $row['value'];
-
- return $map;
- }
-
- public static function set($key, $value) {
- $db = getDb();
- return $db->query("REPLACE INTO config (name, value) VALUES (?, ?)", $key, $value);
- }
-
- public static function mset($map) {
- $rows = [];
- foreach ($map as $name => $value) {
- $rows[] = [
- 'name' => $name,
- 'value' => $value
- ];
- }
- $db = getDb();
- return $db->multipleReplace('config', $rows);
- }
-
-}