aboutsummaryrefslogtreecommitdiffstats
path: root/core/namespace/Post/Repository.php
blob: 5a3d8344ff425664287601e40c9fffeba73c137d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
namespace Post;

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

	public function getCountByUser(\User\Entity $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();
	}
}