aboutsummaryrefslogtreecommitdiff
path: root/models/webpage.php
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2025-01-19 18:40:48 +0200
committerSyndamia <kamen@syndamia.com>2025-01-19 18:40:48 +0200
commit658fd289774d658347ccc5eafa5c140b8ff48d39 (patch)
tree1f2fec9efc9a142c074d6fb902e0aec0157825a9 /models/webpage.php
parent1fedd90926b64f050d7a8f4284fb7a5125fcae16 (diff)
downloadnowayforward_human-658fd289774d658347ccc5eafa5c140b8ff48d39.tar
nowayforward_human-658fd289774d658347ccc5eafa5c140b8ff48d39.tar.gz
nowayforward_human-658fd289774d658347ccc5eafa5c140b8ff48d39.zip
feat(models): Separate user and webpage out of database
Diffstat (limited to 'models/webpage.php')
-rw-r--r--models/webpage.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/models/webpage.php b/models/webpage.php
new file mode 100644
index 0000000..35bb3ce
--- /dev/null
+++ b/models/webpage.php
@@ -0,0 +1,35 @@
+<?php
+namespace Database;
+use PDO;
+
+class Webpage extends Table {
+ public $WID;
+ public $Path;
+ public $URL;
+ public $Date;
+ public $Visits;
+ public $RequesterUID;
+
+ static function create(string $Path, string $URL, int $RequesterUID) : int {
+ return Table::_create(
+ 'Webpages',
+ '(Path, URL, Date, Visits, RequesterUID)',
+ "(\"$Path\", \"$URL\", NOW(), 0, \"$RequesterUID\")"
+ );
+ }
+
+ static function fromDB(string $URL) : Webpage {
+ return Table::_fromDB(
+ "SELECT * FROM Webpages WHERE URL = \"$URL\"",
+ "Database\Webpage"
+ );
+ }
+
+ static function mostVisited(int $count) : array {
+ return Table::_get_all(
+ 'Webpages',
+ 'Database\Webpage',
+ "GROUP BY URL ORDER BY Visits DESC, Date DESC LIMIT $count"
+ );
+ }
+}