blob: ce3ff2c5dd7a516cb776cce116d9770bee148814 (
plain)
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
|
<?php
namespace ORM\Repositories;
use ORM\Repository;
use ORM\Entities\User as UserEntity;
class User extends Repository {
public static function getTableName(): string { return 'user'; }
public static function getClassName(): string { return 'ORM\Entities\User'; }
#===============================================================================
# Get number of *pages* assigned to $User
#===============================================================================
public function getNumberOfPages(UserEntity $User): int {
$query = 'SELECT COUNT(id) FROM %s WHERE user = ?';
$query = sprintf($query, Page::getTableName());
$Statement = $this->Database->prepare($query);
$Statement->execute([$User->getID()]);
return $Statement->fetchColumn();
}
#===============================================================================
# Get number of *posts* assigned to $User
#===============================================================================
public function getNumberOfPosts(UserEntity $User): int {
$query = 'SELECT COUNT(id) FROM %s WHERE user = ?';
$query = sprintf($query, Post::getTableName());
$Statement = $this->Database->prepare($query);
$Statement->execute([$User->getID()]);
return $Statement->fetchColumn();
}
}
|