Total Complexity | 4 |
Total Lines | 52 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
8 | class PaginationModel extends Model{ |
||
9 | |||
10 | private $postsTbl; |
||
11 | |||
12 | public function __construct(Container $container) |
||
13 | { |
||
14 | parent::__construct($container); |
||
15 | $this->postsTbl = $this->getTablePrefix('posts'); |
||
16 | } |
||
17 | |||
18 | |||
19 | /** |
||
20 | * get the total number of posts |
||
21 | * @return int |
||
22 | * @throws \Exception |
||
23 | */ |
||
24 | public function totalNumberPosts(): int |
||
25 | { |
||
26 | $sql = "SELECT COUNT(*) FROM $this->postsTbl WHERE published = 1"; |
||
27 | $this->query($sql); |
||
28 | $this->execute(); |
||
29 | return $this->stmt->fetchColumn(); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * get the total number of posts in a category |
||
34 | * @param int $categoryId |
||
35 | * @return int |
||
36 | * @throws \Exception |
||
37 | */ |
||
38 | public function totalNumberPostsInCategory(int $categoryId): int |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * get the total number of posts in a category |
||
49 | * @param int $authorid |
||
50 | * @return int |
||
51 | * @throws \Exception |
||
52 | */ |
||
53 | public function totalNumberPostsByAuthor(int $authorid):int |
||
60 | } |
||
61 | } |