Improved index.php a bit and added a clean version of database file.
This commit is contained in:
BIN
geo-empty.db
Normal file
BIN
geo-empty.db
Normal file
Binary file not shown.
12
index.php
12
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';
|
||||
|
||||
Reference in New Issue
Block a user