summaryrefslogtreecommitdiff
path: root/html/db.php
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2022-07-28 11:19:17 +0200
committerErich Eckner <git@eckner.net>2022-07-28 11:19:17 +0200
commit76c7c036938be3cb6f90396de51958a90e8bf8b0 (patch)
tree69cbb8a7c303a6bc9fd6fd40d049f2c234324ab4 /html/db.php
parentb68c32227484822f4d213683ef5602328bc17449 (diff)
downloadcolocation-76c7c036938be3cb6f90396de51958a90e8bf8b0.tar.xz
insert lo-keys by ids
Diffstat (limited to 'html/db.php')
-rw-r--r--html/db.php11
1 files changed, 11 insertions, 0 deletions
diff --git a/html/db.php b/html/db.php
index 3e87fcc..9889c71 100644
--- a/html/db.php
+++ b/html/db.php
@@ -25,6 +25,17 @@ class MyDB extends SQLite3 {
die();
return $result;
}
+ function get_state_id($state) {
+ $stm = $this -> prepare('SELECT states.id AS state_id FROM states WHERE states.name = :state');
+ $stm -> bindValue('state', $state);
+ $result = $stm -> execute();
+ if (! $result)
+ die();
+ $result = $result -> fetchArray();
+ if (! $result)
+ die();
+ return $result['state_id'];
+ }
function add_key($comment) {
$stm = $this -> prepare('INSERT INTO keys (key, comment) VALUES (:key, :comment)');
$stm -> bindValue('key', bin2hex(random_bytes(64)));