coalesce on remove individual vote too
This commit is contained in:
parent
094002c442
commit
bf39c8f09f
1 changed files with 6 additions and 1 deletions
|
@ -291,7 +291,12 @@ class NumericScore extends Extension {
|
|||
array("imageid" => $image_id, "userid" => $user_id, "score" => $score));
|
||||
}
|
||||
$database->Execute(
|
||||
"UPDATE images SET numeric_score=(SELECT SUM(score) FROM numeric_score_votes WHERE image_id=:imageid) WHERE id=:id",
|
||||
"UPDATE images SET numeric_score=(
|
||||
COALESCE(
|
||||
(SELECT SUM(score) FROM numeric_score_votes WHERE image_id=:imageid),
|
||||
0
|
||||
)
|
||||
) WHERE id=:id",
|
||||
array("imageid" => $image_id, "id" => $image_id));
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue