Skip to content

Commit

Permalink
fix mysql_get_inputs_v2 to return the same as redis version
Browse files Browse the repository at this point in the history
  • Loading branch information
glynhudson committed Jan 4, 2018
1 parent 255a422 commit bc66982
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Modules/input/input_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,24 @@ private function mysql_get_inputs_v2($userid)
{
$userid = (int) $userid;
$dbinputs = array();
$result = $this->mysqli->query("SELECT nodeid,name,description,processList FROM input WHERE `userid` = '$userid' ORDER BY nodeid,name asc");
$result = $this->mysqli->query("SELECT nodeid,name,description,processList,time,value FROM input WHERE `userid` = '$userid' ORDER BY nodeid,name asc");
while ($row = (array)$result->fetch_object())
{
if ($row['nodeid']==null) $row['nodeid'] = 0;
if (!isset($dbinputs[$row['nodeid']])) $dbinputs[$row['nodeid']] = array();
$dbinputs[$row['nodeid']][$row['name']] = array('processList'=>$row['processList']);

if (!is_numeric($row['time']) || is_nan($row['time'])) {
$row['time'] = null;
} else {
$row['time'] = (int) $row['time'];
}
if (!is_numeric($row['value']) || is_nan($row['value'])) {
$row['value'] = null;
} else {
$row['value'] = (float) $row['value'];
}

$dbinputs[$row['nodeid']][$row['name']] = array('time'=>$row['time'], 'value'=>$row['value'], 'processList'=>$row['processList']);
}
return $dbinputs;
}
Expand Down

0 comments on commit bc66982

Please sign in to comment.