-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuildDb.php
More file actions
38 lines (31 loc) · 873 Bytes
/
buildDb.php
File metadata and controls
38 lines (31 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
use Core\Database;
const BASE_PATH = __DIR__ . DIRECTORY_SEPARATOR;
spl_autoload_register(function ($class) {
$class = BASE_PATH . str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
if (file_exists($class)) {
include $class;
}
});
$buildDb = [
'Users' => 'CREATE TABLE IF NOT EXISTS users(
id INTEGER PRIMARY KEY,
email TEXT,
password TEXT)
',
'Files' => 'CREATE TABLE IF NOT EXISTS files(
id INTEGER PRIMARY KEY,
name TEXT,
temp TEXT,
token TEXT,
removed INTEGER DEFAULT 0,
expire_date TEXT DEFAULT NULL,
count INTEGER DEFAULT 0,
user INTEGER DEFAULT NULL,
FOREIGN KEY (user) REFERENCES users(id))
'
];
foreach ($buildDb as $val) {
Database::query($val);
}
var_dump(Database::query("SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name")->fetchAll());