aboutsummaryrefslogtreecommitdiffstats
path: root/src/app/Models/Post.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/Models/Post.php')
-rw-r--r--src/app/Models/Post.php7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/app/Models/Post.php b/src/app/Models/Post.php
index 66c8c18..e82b0d9 100644
--- a/src/app/Models/Post.php
+++ b/src/app/Models/Post.php
@@ -42,6 +42,13 @@ class Post
return $stmt->fetchAll();
}
+ public function countByUserId(int $userId): int
+ {
+ $stmt = $this->pdo->prepare('SELECT COUNT(*) FROM posts WHERE user_id = :user_id');
+ $stmt->execute(['user_id' => $userId]);
+ return (int) $stmt->fetchColumn();
+ }
+
public function findAllPaginated(int $limit, int $offset): array
{
$stmt = $this->pdo->prepare(