diff options
| author | Michael Foster <savetheinternet@tinyboard.org> | 2013-07-31 20:51:43 -0400 |
|---|---|---|
| committer | Michael Foster <savetheinternet@tinyboard.org> | 2013-07-31 20:51:43 -0400 |
| commit | 328484bee7cab9ce354121413cc8d96c3e227aea (patch) | |
| tree | 7adf01c48cbe1970c159da182292b5c7ed48d958 /templates/themes/recent/theme.php | |
| parent | 6bbe407e18681f2812db4345036bb5ae639f5973 (diff) | |
SQL cleanup
Diffstat (limited to 'templates/themes/recent/theme.php')
| -rw-r--r-- | templates/themes/recent/theme.php | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/templates/themes/recent/theme.php b/templates/themes/recent/theme.php index 75907e77..98fabfa1 100644 --- a/templates/themes/recent/theme.php +++ b/templates/themes/recent/theme.php @@ -47,7 +47,7 @@ $query = preg_replace('/UNION ALL $/', 'ORDER BY `time` DESC LIMIT ' . (int)$settings['limit_images'], $query); $query = query($query) or error(db_error()); - while ($post = $query->fetch()) { + while ($post = $query->fetch(PDO::FETCH_ASSOC)) { openBoard($post['board']); // board settings won't be available in the template file, so generate links now @@ -67,7 +67,7 @@ $query = preg_replace('/UNION ALL $/', 'ORDER BY `time` DESC LIMIT ' . (int)$settings['limit_posts'], $query); $query = query($query) or error(db_error()); - while ($post = $query->fetch()) { + while ($post = $query->fetch(PDO::FETCH_ASSOC)) { openBoard($post['board']); $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], ($post['thread'] ? $post['thread'] : $post['id'])) . '#' . $post['id']; @@ -78,7 +78,7 @@ } // Total posts - $query = 'SELECT SUM(`top`) AS `count` FROM ('; + $query = 'SELECT SUM(`top`) FROM ('; foreach ($boards as &$_board) { if (in_array($_board['uri'], $this->excluded)) continue; @@ -86,11 +86,10 @@ } $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query); $query = query($query) or error(db_error()); - $res = $query->fetch(); - $stats['total_posts'] = number_format($res['count']); + $stats['total_posts'] = number_format($query->fetchColumn()); // Unique IPs - $query = 'SELECT COUNT(DISTINCT(`ip`)) AS `count` FROM ('; + $query = 'SELECT COUNT(DISTINCT(`ip`)) FROM ('; foreach ($boards as &$_board) { if (in_array($_board['uri'], $this->excluded)) continue; @@ -98,11 +97,10 @@ } $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query); $query = query($query) or error(db_error()); - $res = $query->fetch(); - $stats['unique_posters'] = number_format($res['count']); + $stats['unique_posters'] = number_format($query->fetchColumn()); // Active content - $query = 'SELECT SUM(`filesize`) AS `count` FROM ('; + $query = 'SELECT SUM(`filesize`) FROM ('; foreach ($boards as &$_board) { if (in_array($_board['uri'], $this->excluded)) continue; @@ -110,8 +108,7 @@ } $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query); $query = query($query) or error(db_error()); - $res = $query->fetch(); - $stats['active_content'] = $res['count']; + $stats['active_content'] = $query->fetchColumn(); return Element('themes/recent/recent.html', Array( 'settings' => $settings, |
