summaryrefslogtreecommitdiff
path: root/html/db.php
diff options
context:
space:
mode:
Diffstat (limited to 'html/db.php')
-rw-r--r--html/db.php12
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();
}
}