summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2022-07-28 17:40:11 +0200
committerErich Eckner <git@eckner.net>2022-07-28 17:40:11 +0200
commit0db78b654f3add280e5532962eef21c8601c771b (patch)
tree685996981cbae09b68c5ccf140a2ba70c4f3d96b
parent53dcd7604c077f2a46383f89843e967f0ee9f567 (diff)
downloadcolocation-0db78b654f3add280e5532962eef21c8601c771b.tar.xz
value=0 should be minimal state, value=1 should stay maximal state
-rw-r--r--html/index.php4
1 files changed, 2 insertions, 2 deletions
diff --git a/html/index.php b/html/index.php
index 8fb46da..df6d4dc 100644
--- a/html/index.php
+++ b/html/index.php
@@ -3,7 +3,7 @@
include "db.php";
$result = $db -> query(
- 'SELECT machines.id as machine, MIN(states.id) as min_state' .
+ 'SELECT machines.id as machine, IIF("values".value = 1, MIN(states.id), MAX(states.id)) as minax_state' .
' FROM machines' .
' JOIN "values" ON machines.id = "values".machine_id' .
' JOIN states ON "values".state_id = states.id' .
@@ -23,7 +23,7 @@ $values = array();
while ($row = $result -> fetchArray()) {
$stm -> bindValue('machine', $row['machine']);
- $stm -> bindValue('state', $row['min_state']);
+ $stm -> bindValue('state', $row['minax_state']);
$stmres = $stm -> execute();
$stmres = $stmres -> fetchArray();
$values[$row['machine']][$stmres['value']] = $stmres;