aboutsummaryrefslogtreecommitdiffstats
path: root/core/namespace/ORM/Repositories/Post.php
blob: 8eac12fd991f37ccee7b304a39c76776020e414d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
namespace ORM\Repositories;
use ORM\Repository;
use ORM\Entities\User;

class Post extends Repository {
	public static function getTableName(): string { return 'post'; }
	public static function getClassName(): string { return 'ORM\Entities\Post'; }

	public function getCountByUser(User $User): int {
		$query = 'SELECT COUNT(id) FROM %s WHERE user = ?';
		$query = sprintf($query, static::getTableName());

		$Statement = $this->Database->prepare($query);
		$Statement->execute([$User->getID()]);

		return $Statement->fetchColumn();
	}
}