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/serversetup-bwlp-ipxe/inc | |
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/serversetup-bwlp-ipxe/inc')
3 files changed, 5 insertions, 5 deletions
diff --git a/modules-available/serversetup-bwlp-ipxe/inc/bootentry.inc.php b/modules-available/serversetup-bwlp-ipxe/inc/bootentry.inc.php index 8aef52e7..08b65ed6 100644 --- a/modules-available/serversetup-bwlp-ipxe/inc/bootentry.inc.php +++ b/modules-available/serversetup-bwlp-ipxe/inc/bootentry.inc.php @@ -121,7 +121,7 @@ abstract class BootEntry { $res = Database::simpleQuery("SELECT entryid, data FROM serversetup_bootentry"); $ret = []; - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { $tmp = self::fromJson($row['module'], $row['data']); if ($tmp === null) continue; diff --git a/modules-available/serversetup-bwlp-ipxe/inc/ipxe.inc.php b/modules-available/serversetup-bwlp-ipxe/inc/ipxe.inc.php index e2e90c2a..8731bb7a 100644 --- a/modules-available/serversetup-bwlp-ipxe/inc/ipxe.inc.php +++ b/modules-available/serversetup-bwlp-ipxe/inc/ipxe.inc.php @@ -18,7 +18,7 @@ class IPxe { $res = Database::simpleQuery('SELECT menuid, entryid FROM serversetup_menuentry ORDER BY sortval ASC'); $menus = []; - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { if (!isset($menus[$row['menuid']])) { $menus[(int)$row['menuid']] = []; } @@ -40,7 +40,7 @@ class IPxe WHERE startaddr >= :start AND endaddr <= :end", compact('start', 'end')); $locations = []; // Iterate over result, eliminate those that are dominated by others - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { foreach ($locations as &$loc) { if ($row['startaddr'] <= $loc['startaddr'] && $row['endaddr'] >= $loc['endaddr']) { $loc = false; diff --git a/modules-available/serversetup-bwlp-ipxe/inc/ipxemenu.inc.php b/modules-available/serversetup-bwlp-ipxe/inc/ipxemenu.inc.php index b1e13e87..587d9200 100644 --- a/modules-available/serversetup-bwlp-ipxe/inc/ipxemenu.inc.php +++ b/modules-available/serversetup-bwlp-ipxe/inc/ipxemenu.inc.php @@ -43,7 +43,7 @@ class IPxeMenu LEFT JOIN serversetup_bootentry b USING (entryid) WHERE e.menuid = :menuid ORDER BY e.sortval ASC, e.title ASC", ['menuid' => $menu['menuid']]); - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { $this->items[] = new MenuEntry($row); } // Make sure we have a default entry if the menu isn't empty @@ -109,7 +109,7 @@ class IPxeMenu if ($res->rowCount() > 0) { // Make the location id key, preserving order (closest location is first) $chain = array_flip($chain); - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { // Overwrite the value (numeric ascending values, useless) with menu array of according location $chain[(int)$row['locationid']] = $row; } |