From b7e04cbf3824a8d5cd535c8cb00a6a697b977bf9 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 19 Jan 2025 08:31:20 +0200 Subject: feat(database): Implement Webpage class --- models/database.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'models') diff --git a/models/database.php b/models/database.php index cd4bf77..f1531f5 100644 --- a/models/database.php +++ b/models/database.php @@ -28,6 +28,30 @@ class User extends Table { } } +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( + 'Webpage', + '(Path, URL, Date, Visits, RequesterUID)', + "(\"$Path\", \"$URL\", NOW(), 0, \"$RequesterUID\")" + ); + } + + static function fromDB(string $URL) : Webpage { + return Table::_fromDB( + "SELECT * FROM Webpage WHERE URL = \"$URL\"", + "Database\Webpage" + ); + } +} + abstract class Table { // Cannot be created, because FETCH_CLASS will assign to all attributes // and then call the constructor -- cgit v1.2.3