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/syslog/api.inc.php | 2 +- modules-available/syslog/page.inc.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'modules-available/syslog') diff --git a/modules-available/syslog/api.inc.php b/modules-available/syslog/api.inc.php index da3e1519..3378afe6 100644 --- a/modules-available/syslog/api.inc.php +++ b/modules-available/syslog/api.inc.php @@ -25,7 +25,7 @@ if (($user = Request::post('export-user', false, 'string')) !== false) { unset($best); foreach ($srcs as &$src) { if (!isset($src['row'])) { - $src['row'] = $src['res']->fetch(PDO::FETCH_ASSOC); + $src['row'] = $src['res']->fetch(); } if ($src['row'] !== false && (!isset($best) || $src['row']['dateline'] < $best['dateline'])) { $best =& $src['row']; diff --git a/modules-available/syslog/page.inc.php b/modules-available/syslog/page.inc.php index 410a1ed7..71a07e14 100644 --- a/modules-available/syslog/page.inc.php +++ b/modules-available/syslog/page.inc.php @@ -61,7 +61,7 @@ class Page_SysLog extends Page WHERE dateline > $cutoff GROUP BY logtypeid ORDER BY counter ASC"); $types = array(); - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { $types[$row['logtypeid']] = $row; } if (Request::get('filter') !== false || Request::get('search') !== false) { @@ -112,7 +112,7 @@ class Page_SysLog extends Page WHERE $whereClause ORDER BY logid DESC", 50); $res = $paginate->exec($qArgs); - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { $row['date'] = Util::prettyTime($row['dateline']); $row['icon'] = $this->eventToIconName($row['logtypeid']); $lines[] = $row; -- cgit v1.2.3-55-g7522