Improved index.php a bit and added a clean version of database file.

This commit is contained in:
2017-07-18 11:54:52 +02:00
parent f0f07b7ae7
commit 3b60f34ebd
2 changed files with 1 additions and 11 deletions

BIN
geo-empty.db Normal file

Binary file not shown.

View File

@@ -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';