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/statistics/page.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules-available/statistics/page.inc.php') diff --git a/modules-available/statistics/page.inc.php b/modules-available/statistics/page.inc.php index 20ff929a..6224d69c 100644 --- a/modules-available/statistics/page.inc.php +++ b/modules-available/statistics/page.inc.php @@ -171,7 +171,7 @@ class Page_Statistics extends Page $ids = array_flip($ids); $allowedMachines = []; $seenLocations = []; - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { unset($ids[$row['machineuuid']]); settype($row['locationid'], 'int'); if (in_array($row['locationid'], $allowedLocations)) { @@ -202,7 +202,7 @@ class Page_Statistics extends Page $res = Database::simpleQuery('SELECT machineuuid, locationid FROM machine WHERE machineuuid IN (:ids)', compact('ids')); $ids = array_flip($ids); $delete = []; - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { unset($ids[$row['machineuuid']]); if (in_array($row['locationid'], $allowedLocations)) { $delete[] = $row['machineuuid']; -- cgit v1.2.3-55-g7522