From 17d09f4b993767e7ad794d155cf66112a9bf3be2 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 19 Jan 2025 19:46:18 +0200 Subject: feat(models/webpage): Fix logic for get_all --- models/database.php | 4 ++-- models/webpage.php | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/models/database.php b/models/database.php index 45be65b..62f5b10 100644 --- a/models/database.php +++ b/models/database.php @@ -39,9 +39,9 @@ abstract class Table { $conn = null; } - static protected function _get_all(string $table, string $class, string $additional = null) : array { + static protected function _get_all(string $table, string $class, string $additional = null, $columns = "*") : array { $conn = Table::connect(); - $query = $conn->query("SELECT * FROM $table " . $additional); + $query = $conn->query("SELECT $columns FROM $table " . $additional); $conn = null; $query->setFetchMode(PDO::FETCH_CLASS, $class); diff --git a/models/webpage.php b/models/webpage.php index 9dcc5ae..a7fa1b9 100644 --- a/models/webpage.php +++ b/models/webpage.php @@ -29,7 +29,8 @@ class Webpage extends Table { return Table::_get_all( 'Webpages', 'Database\Webpage', - "GROUP BY URL ORDER BY Visits DESC, Date DESC LIMIT $count" + "GROUP BY URL ORDER BY Visits DESC, Date DESC LIMIT $count", + 'WID,Path,URL,Date,MAX(Visits) as Visits,RequesterUID' ); } -- cgit v1.2.3