From a70d53434ac85bbe3f33e31d29947bbb411115f1 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Thu, 28 Jul 2022 11:23:14 +0200 Subject: get_machine_id new --- html/db.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/html/db.php b/html/db.php index 9889c71..4c4fdc7 100644 --- a/html/db.php +++ b/html/db.php @@ -45,6 +45,18 @@ class MyDB extends SQLite3 { $stm -> close(); return $key_id; } + function get_machine_id($machine) { + $stm = $this -> prepare('SELECT machines.id AS machine_id FROM machines WHERE machines.name=:name'); + $stm -> bindValue('name', $machine); + $result = $stm -> execute(); + $result = $result -> fetchArray(); + $stm -> close(); + + if (! $result) + return NULL; + else + return $result['machine_id']; + } function add_machine($machine) { $stm = $this -> prepare('SELECT COUNT(1) FROM machines WHERE machines.name=:name'); $stm -> bindValue('name', $machine); -- cgit v1.2.3-54-g00ecf