diff options
author | Erich Eckner <git@eckner.net> | 2022-07-28 10:13:59 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2022-07-28 10:13:59 +0200 |
commit | b9cd023d3c8465f9efc53596450364287a6f3cbc (patch) | |
tree | 53dca5dbec4350eeaa000c29b0cd804d0ab4f509 | |
parent | 0fde09f12b965912be7f731d70a7869750d2d821 (diff) | |
download | colocation-b9cd023d3c8465f9efc53596450364287a6f3cbc.tar.xz |
html/db.php: use $this
-rw-r--r-- | html/db.php | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/html/db.php b/html/db.php index cca6d74..7af33f9 100644 --- a/html/db.php +++ b/html/db.php @@ -26,16 +26,16 @@ class MyDB extends SQLite3 { return $result; } function add_key() { - $stm = prepare('INSERT INTO keys (key) VALUES (:key)'); + $stm = $this -> prepare('INSERT INTO keys (key) VALUES (:key)'); $stm -> bindValue('key', bin2hex(random_bytes(64))); $stm -> execute(); - $key_id = $db -> lastInsertRowID(); + $key_id = $this -> lastInsertRowID(); $stm -> close(); return $key_id; } function get_value_id_of($machine, $state) { if (is_int($machine) && is_int($state)) { - $stm = $db -> prepare( + $stm = $this -> prepare( 'SELECT "values".id as value_id FROM "values"' . ' WHERE "values".state_id = :state_id' . ' AND "values".machine_id = :machine_id' @@ -43,7 +43,7 @@ class MyDB extends SQLite3 { $stm -> bindValue('state_id', $state); $stm -> bindValue('machine_id', $machine); } else { - $stm = $db -> prepare( + $stm = $this -> prepare( 'SELECT "values".id as value_id FROM "values"' . ' JOIN states ON states.id = "values".state_id' . ' JOIN machines ON machines.id = "values".machine_id' . @@ -63,9 +63,9 @@ class MyDB extends SQLite3 { return $result['value_id']; } function add_key_for($machine, $state) { - $key_id = add_key(); - $value_id = get_value_id_of($machine, $state); - $stm = $db -> prepare( + $key_id = $this -> add_key(); + $value_id = $this -> get_value_id_of($machine, $state); + $stm = $this -> prepare( 'INSERT INTO permissions (key_id, value_id) VALUES (:key,:value)'); $stm -> bindValue('value', $value_id); $stm -> bindValue('key', $key_id); |