aboutsummaryrefslogtreecommitdiffstats
path: root/core/namespace/Post/Repository.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/namespace/Post/Repository.php')
-rw-r--r--core/namespace/Post/Repository.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/core/namespace/Post/Repository.php b/core/namespace/Post/Repository.php
new file mode 100644
index 0000000..5a3d834
--- /dev/null
+++ b/core/namespace/Post/Repository.php
@@ -0,0 +1,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();
+ }
+}