aboutsummaryrefslogtreecommitdiff
path: root/models/webpage.php
diff options
context:
space:
mode:
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"
+ );
+ }
+}