Website Summary Files Commits Branches @commit @diff @stats
path: root / models / webpage.php
diff options
context:
space:
mode:
Commit640dd416d3de28ad39b05747ad4b7c81d5203776 (patch)
Author
 Syndamia <kamen@syndamia.com>
2025-01-19 19:25:03 +0200
Committer
 Syndamia <kamen@syndamia.com>
2025-01-19 19:25:03 +0200
Files593014a96312038e8dc3ce876fe041d6c9d387a3 /models/webpage.php
nowayforward_human-640dd416d3de28ad39b05747ad4b7c81d5203776.tar
nowayforward_human-640dd416d3de28ad39b05747ad4b7c81d5203776.tar.gz
nowayforward_human-640dd416d3de28ad39b05747ad4b7c81d5203776.zip
Parenteeca9f447abbecb5e2173154499a3cd7f75977ea (diff)
feat(models/webpage): Add functions for getting all archives and updating the visits count
1 files changed, 17 insertions, 1 deletions
-rw-r--r--models/webpage.php18
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}\""
+ );
+ }
}