1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
<?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\" ORDER BY Date DESC LIMIT 1",
"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"
);
}
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}\""
);
}
}
|