coalesce on remove individual vote too

This commit is contained in:
Shish 2012-03-30 17:48:03 +01:00
parent 094002c442
commit bf39c8f09f

View file

@ -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));
}
}