BTTM

BTTM\DataBase

Apr 30th, 2021 (edited)
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.55 KB | None | 0 0
  1. <?php
  2.     /*
  3.         - A simple KeyValue NoSQL DataBase using flat files!
  4.     */
  5.  
  6.     namespace BTTM;
  7.  
  8.     class DataBase {
  9.         function __construct() {
  10.             if (!file_exists('{{base}}/db/')) mkdir('{{base}}/db/');
  11.         }
  12.         function get($key) {
  13.             return file_get_contents('{{base}}/db/'.$key.'.txt');
  14.         }
  15.         function set($key, $val) {
  16.             return file_put_contents('{{base}}/db/'.$key.'.txt', $val);
  17.         }
  18.         function delete($key) {
  19.             return unlink('{{base}}/db/'.$key.'.txt');
  20.         }
  21.         function has($key) {
  22.             return file_exists('{{base}}/db/'.$key.'.txt');
  23.         }
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment