diff options
author | Erich Eckner <git@eckner.net> | 2022-07-28 13:12:43 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2022-07-28 13:12:43 +0200 |
commit | 53dcd7604c077f2a46383f89843e967f0ee9f567 (patch) | |
tree | b7d815da6f7839909db1d8b506dd906e504ea934 /html/db.php | |
parent | 2b4d629419f4d9d82d736050e943793b5a778ea9 (diff) | |
download | colocation-53dcd7604c077f2a46383f89843e967f0ee9f567.tar.xz |
add single lo key for power and ping
Diffstat (limited to 'html/db.php')
-rw-r--r-- | html/db.php | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/html/db.php b/html/db.php index fee5ef6..960cbd3 100644 --- a/html/db.php +++ b/html/db.php @@ -128,14 +128,18 @@ class MyDB extends SQLite3 { $stm -> close(); return $result['value_id']; } - function add_key_for($machine, $state, $comment) { + function add_key_for($machine, $states, $comment) { $key_id = $this -> add_key($comment); - $value_id = $this -> get_value_id_of($machine, $state); + if (!is_array($states)) + $states = array($states); $stm = $this -> prepare( 'INSERT INTO permissions (key_id, value_id) VALUES (:key,:value)'); - $stm -> bindValue('value', $value_id); $stm -> bindValue('key', $key_id); - $stm -> execute(); + foreach ($states as $state) { + $value_id = $this -> get_value_id_of($machine, $state); + $stm -> bindValue('value', $value_id); + $stm -> execute(); + } $stm -> close(); } } |