-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
2,003 additions
and
339 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
RewriteEngine On | ||
RewriteCond %{REQUEST_FILENAME} !-f | ||
RewriteCond %{REQUEST_FILENAME} !-d | ||
RewriteRule ^ index.php [QSA,L] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
class LochDbMigrator | ||
{ | ||
public static function MigrateDb(PDO $pdo) | ||
{ | ||
self::ExecuteMigrationWhenNeeded($pdo, 1, " | ||
CREATE TABLE IF NOT EXISTS locationpoints ( | ||
id INT(11) NOT NULL AUTO_INCREMENT, | ||
time DATETIME NOT NULL, | ||
latitude DECIMAL(10, 8) NOT NULL, | ||
longitude DECIMAL(11, 8) NOT NULL, | ||
accuracy DECIMAL(8, 3) NOT NULL, | ||
import_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
distance_to_point_before INT(11) DEFAULT NULL, | ||
PRIMARY KEY (id), | ||
KEY time (time) | ||
)" | ||
); | ||
} | ||
|
||
private static function ExecuteMigrationWhenNeeded(PDO $pdo, int $migrationId, string $sql) | ||
{ | ||
$rowCount = $pdo->query('SELECT COUNT(*) FROM migrations WHERE migration = ' . $migrationId)->fetchColumn(); | ||
if (intval($rowCount) === 0) | ||
{ | ||
$pdo->exec(utf8_encode($sql)); | ||
$statement = $pdo->prepare('INSERT INTO migrations (migration) VALUES (:id)'); | ||
$statement->bindValue(':id', $migrationId); | ||
$statement->execute(); | ||
} | ||
} | ||
} |
Oops, something went wrong.