From 53dcd7604c077f2a46383f89843e967f0ee9f567 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Thu, 28 Jul 2022 13:12:43 +0200 Subject: add single lo key for power and ping --- html/db.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'html/db.php') 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(); } } -- cgit v1.2.3-54-g00ecf