diff --git a/geo-empty.db b/geo-empty.db new file mode 100644 index 0000000..39717d3 Binary files /dev/null and b/geo-empty.db differ diff --git a/index.php b/index.php index c683c67..25c7730 100644 --- a/index.php +++ b/index.php @@ -9,11 +9,11 @@ $path = strtolower(trim(stripslashes(isset($_GET['path']) ? $_GET['path'] : ''), list($action, $parameter) = array_pad(explode('/', $path), 2, null); +$db = new SQLite3('geo.db'); switch ($action) { case 'list': - $db = new SQLite3('geo.db'); $results = $db->query('SELECT * FROM location ORDER BY cre_dt DESC'); $rows = []; while ($row = $results->fetchArray(SQLITE3_ASSOC)) { @@ -25,8 +25,6 @@ switch ($action) { break; case 'delete': - $db = new SQLite3('geo.db'); - $stmt = $db->prepare('DELETE FROM location WHERE id = :id'); $stmt->bindValue(':id', $parameter, SQLITE3_INTEGER); $entry = $stmt->execute(); @@ -34,8 +32,6 @@ switch ($action) { break; case 'edit': - - $db = new SQLite3('geo.db'); $stmt = $db->prepare('SELECT * FROM location WHERE id = :id'); $stmt->bindValue(':id', $parameter, SQLITE3_INTEGER); $entry = $stmt->execute(); @@ -43,9 +39,6 @@ switch ($action) { include 'templates/edit.php'; break; case 'save': - - $db = new SQLite3('geo.db'); - //edycja if (isset($parameter) && !is_null($parameter) && (int)$parameter > 0) { $stmt = $db->prepare('UPDATE location SET title=:title, description=:description, dl=:dl, szer=:szer, up_dt=:up_dt WHERE id=:id'); @@ -70,15 +63,12 @@ switch ($action) { break; case 'mapa': - $db = new SQLite3('geo.db'); $results = $db->query('SELECT * FROM location ORDER BY cre_dt DESC'); $rows = []; while ($row = $results->fetchArray(SQLITE3_ASSOC)) { $rows[] = $row; } - include 'templates/mapa.php'; - break; default: include 'templates/main.php';