diff options
author | Erich Eckner <git@eckner.net> | 2022-07-28 11:23:14 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2022-07-28 11:23:14 +0200 |
commit | a70d53434ac85bbe3f33e31d29947bbb411115f1 (patch) | |
tree | dce0339d6673da912695339551f452f316c842d5 | |
parent | 76c7c036938be3cb6f90396de51958a90e8bf8b0 (diff) | |
download | colocation-a70d53434ac85bbe3f33e31d29947bbb411115f1.tar.xz |
get_machine_id new
-rw-r--r-- | html/db.php | 12 |
1 files changed, 12 insertions, 0 deletions
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); |