From 1192a6d123a5e1b396bbdf4dffba8517b74e0081 Mon Sep 17 00:00:00 2001 From: shish <shish@7f39781d-f577-437e-ae19-be835c7a54ca> Date: Sun, 21 Oct 2007 22:59:47 +0000 Subject: [PATCH] mysql-specificness :< git-svn-id: file:///home/shish/svn/shimmie2/trunk@545 7f39781d-f577-437e-ae19-be835c7a54ca --- contrib/numeric_score/main.php | 3 +-- contrib/text_score/main.php | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/contrib/numeric_score/main.php b/contrib/numeric_score/main.php index f68adb00..3e6b1f6f 100644 --- a/contrib/numeric_score/main.php +++ b/contrib/numeric_score/main.php @@ -87,9 +87,8 @@ class NumericScore extends Extension { private function add_vote($image_id, $user_id, $score) { global $database; - // TODO: update if already voted $database->Execute( - "INSERT INTO numeric_score_votes(image_id, user_id, score) VALUES(?, ?, ?)", + "REPLACE INTO numeric_score_votes(image_id, user_id, score) VALUES(?, ?, ?)", array($image_id, $user_id, $score)); $database->Execute( "UPDATE images SET numeric_score=(SELECT SUM(score) FROM numeric_score_votes WHERE image_id=?) WHERE id=?", diff --git a/contrib/text_score/main.php b/contrib/text_score/main.php index 06081a8e..dafd7c50 100644 --- a/contrib/text_score/main.php +++ b/contrib/text_score/main.php @@ -89,7 +89,7 @@ class TextScore extends Extension { global $database; // TODO: update if already voted $database->Execute( - "INSERT INTO text_score_votes(image_id, user_id, score) VALUES(?, ?, ?)", + "REPLACE INTO text_score_votes(image_id, user_id, score) VALUES(?, ?, ?)", array($image_id, $user_id, $score)); $database->Execute( "UPDATE images SET text_score=(SELECT AVG(score) FROM text_score_votes WHERE image_id=?) WHERE id=?",