From 8dc2b92d667f1401ab9f1315a36add61658f899c Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 6 May 2021 10:26:09 +0200 Subject: Moderize Database handling * Auto-convert to utf8mb4_unicode_520_ci * Use foreach instead of while to loop over results * Drop useless statement caching * Keep emulated prepares, as we sometimes loop over nested queries --- modules-available/runmode/inc/runmode.inc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'modules-available/runmode/inc/runmode.inc.php') diff --git a/modules-available/runmode/inc/runmode.inc.php b/modules-available/runmode/inc/runmode.inc.php index 4d077f02..ccc432d2 100644 --- a/modules-available/runmode/inc/runmode.inc.php +++ b/modules-available/runmode/inc/runmode.inc.php @@ -139,7 +139,7 @@ class RunMode $res = Database::simpleQuery('SELECT machineuuid, modeid, modedata FROM runmode WHERE module = :module', compact('module')); $ret = array(); - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { if ($groupByModeId) { if (!isset($ret[$row['modeid']])) { $ret[$row['modeid']] = array(); @@ -177,7 +177,7 @@ class RunMode WHERE module = :module AND modeid = :modeId", compact('module', 'modeId')); $ret = array(); - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { if ($detailed && empty($row['hostname'])) { $row['hostname'] = $row['clientip']; } @@ -204,7 +204,7 @@ class RunMode } $res = Database::simpleQuery("SELECT machineuuid, module, modeid, isclient $xtra FROM runmode"); $ret = array(); - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { if (!is_null($isClient) && ($row['isclient'] != 0) !== $isClient) continue; $ret[$row['machineuuid']] = $row; -- cgit v1.2.3-55-g7522