prepared comment counting
This commit is contained in:
@@ -31,5 +31,6 @@ CREATE INDEX idx_comments_browser ON comments(browser_id);
|
||||
-- ---------------------------------------------------------------------
|
||||
ALTER TABLE contributions
|
||||
ADD COLUMN photo_path VARCHAR(255) DEFAULT NULL;
|
||||
ADD COLUMN comment_count INTEGER NOT NULL DEFAULT 0;
|
||||
|
||||
COMMENT ON COLUMN contributions.photo_path IS 'Relative Path to uploaded Photo. NULL = no Photo.';
|
||||
@@ -629,6 +629,14 @@ function handle_create_comment($input) {
|
||||
':content' => $input['content']
|
||||
]);
|
||||
|
||||
$stmt2 = $pdo->prepare("
|
||||
UPDATE contributions
|
||||
SET comment_count = comment_count + 1
|
||||
WHERE id = :cid;
|
||||
");
|
||||
|
||||
$stmt2->execute([':cid' => $input['contribution_id']]);
|
||||
|
||||
json_response([
|
||||
'message' => 'Comment created successfully.',
|
||||
'comment_id' => (int) $pdo->lastInsertId()
|
||||
|
||||
Reference in New Issue
Block a user