diff options
author | Simon Rettberg | 2021-05-06 10:26:09 +0200 |
---|---|---|
committer | Simon Rettberg | 2021-05-11 14:51:13 +0200 |
commit | 8dc2b92d667f1401ab9f1315a36add61658f899c (patch) | |
tree | 452c5fe040055884cf9d9ee834415db84999a9a1 /modules-available/runmode/page.inc.php | |
parent | [session] Add simple session overview table (diff) | |
download | slx-admin-8dc2b92d667f1401ab9f1315a36add61658f899c.tar.gz slx-admin-8dc2b92d667f1401ab9f1315a36add61658f899c.tar.xz slx-admin-8dc2b92d667f1401ab9f1315a36add61658f899c.zip |
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
Diffstat (limited to 'modules-available/runmode/page.inc.php')
-rw-r--r-- | modules-available/runmode/page.inc.php | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/modules-available/runmode/page.inc.php b/modules-available/runmode/page.inc.php index 0b6dfa02..a551ddc5 100644 --- a/modules-available/runmode/page.inc.php +++ b/modules-available/runmode/page.inc.php @@ -198,15 +198,17 @@ class Page_RunMode extends Page { if ($onlyModule === false) { $where = ''; + $args = []; } else { $where = ' AND r.module = :moduleId '; + $args = ['moduleId' => $onlyModule]; } $res = Database::simpleQuery("SELECT m.machineuuid, m.hostname, m.clientip, r.module, r.modeid, r.isclient" . " FROM runmode r" . " INNER JOIN machine m ON (m.machineuuid = r.machineuuid $where )" - . " ORDER BY m.hostname ASC, m.clientip ASC", array('moduleId' => $onlyModule)); + . " ORDER BY m.hostname ASC, m.clientip ASC", $args); $modules = array(); - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { if (!isset($modules[$row['module']])) { if (!Module::isAvailable($row['module'])) continue; @@ -332,7 +334,7 @@ class Page_RunMode extends Page LIMIT 100", $params); $returnObject = [ - 'machines' => $result->fetchAll(PDO::FETCH_ASSOC) + 'machines' => $result->fetchAll() ]; } } |