initialize db if not found

This commit is contained in:
Tomáš Mládek 2019-11-04 17:52:17 +01:00
parent 18a1358ef2
commit 4b54f5919a

15
api.php
View file

@ -1,6 +1,19 @@
<?php
$database = new SQLite3('outchat.db');
$initialized = file_exists('outchat.db');
try {
$database = new SQLite3('outchat.db');
} catch (Exception $exception) {
http_response_code(500);
echo $exception;
die(-1);
}
if (!$initialized) {
$database->exec(file_get_contents("outchat-ddl.sql"));
}
$action = $_GET['action'];