diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..73afc4d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea +src/data/*.db diff --git a/src/data/.gitkeep b/src/data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/lib/Data.php b/src/lib/Data.php new file mode 100644 index 0000000..d134744 --- /dev/null +++ b/src/lib/Data.php @@ -0,0 +1,62 @@ +exec('PRAGMA foreign_keys = ON;'); + return $db; + } + + public static function ensureDb(): void { + $db = self::getConnection(); + $tables = $db->query("SELECT name FROM sqlite_master WHERE type = 'table'")->fetchArray(SQLITE3_NUM); + if (!array_search('frc_user', $tables)) { + $query = <<exec($query); + $db->exec('CREATE INDEX idx_user_email ON frc_user (email)'); + } + if (!array_search('feed', $tables)) { + $query = <<exec($query); + } + if (!array_search('item', $tables)) { + $query = <<exec($query); + } + $db->close(); + } +} + +Data::ensureDb(); diff --git a/src/start.php b/src/start.php new file mode 100644 index 0000000..50517c1 --- /dev/null +++ b/src/start.php @@ -0,0 +1,20 @@ +