comment counter now refreshed for each deletion or addition of comment
This commit is contained in:
@@ -664,6 +664,14 @@ function handle_delete_comment($input) {
|
||||
$stmt = $pdo->prepare("DELETE FROM comments WHERE comment_id = :id");
|
||||
$stmt->execute([':id' => $input['comment_id']]);
|
||||
|
||||
$stmt2 = $pdo->prepare("
|
||||
UPDATE contributions
|
||||
SET comment_count = comment_count - 1
|
||||
WHERE contribution_id = :cid;
|
||||
");
|
||||
|
||||
$stmt2->execute([':cid' => $input['contribution_id']]);
|
||||
|
||||
json_response(['message' => 'Comment deleted successfully.']);
|
||||
|
||||
} catch (PDOException $e) {
|
||||
|
||||
Reference in New Issue
Block a user