aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2025-01-19 19:25:03 +0200
committerSyndamia <kamen@syndamia.com>2025-01-19 19:25:03 +0200
commit640dd416d3de28ad39b05747ad4b7c81d5203776 (patch)
tree593014a96312038e8dc3ce876fe041d6c9d387a3
parenteeca9f447abbecb5e2173154499a3cd7f75977ea (diff)
downloadnowayforward_human-640dd416d3de28ad39b05747ad4b7c81d5203776.tar
nowayforward_human-640dd416d3de28ad39b05747ad4b7c81d5203776.tar.gz
nowayforward_human-640dd416d3de28ad39b05747ad4b7c81d5203776.zip
feat(models/webpage): Add functions for getting all archives and updating the visits count
-rw-r--r--models/webpage.php18
1 files changed, 17 insertions, 1 deletions
diff --git a/models/webpage.php b/models/webpage.php
index 35bb3ce..9dcc5ae 100644
--- a/models/webpage.php
+++ b/models/webpage.php
@@ -20,7 +20,7 @@ class Webpage extends Table {
static function fromDB(string $URL) : Webpage {
return Table::_fromDB(
- "SELECT * FROM Webpages WHERE URL = \"$URL\"",
+ "SELECT * FROM Webpages WHERE URL = \"$URL\" ORDER BY Date DESC LIMIT 1",
"Database\Webpage"
);
}
@@ -32,4 +32,20 @@ class Webpage extends Table {
"GROUP BY URL ORDER BY Visits DESC, Date DESC LIMIT $count"
);
}
+
+ static function allArchives(string $URL) : array {
+ return Table::_get_all(
+ 'Webpages',
+ 'Database\Webpage',
+ "WHERE URL = \"$URL\" ORDER BY Date DESC"
+ );
+ }
+
+ function incrementVisits() {
+ Table::_update(
+ 'Webpages',
+ "Visits = \"" . ($this->Visits + 1) . "\"",
+ "WID = \"{$this->WID}\""
+ );
+ }
}