]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
update only one bookmark when voting;
authorcweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>
Wed, 28 Oct 2009 08:03:08 +0000 (08:03 +0000)
committercweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>
Wed, 28 Oct 2009 08:03:08 +0000 (08:03 +0000)
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@446 b3834d28-1941-0410-a4f8-b48e95affb8f

src/SemanticScuttle/Service/Vote.php

index 6db940cc9073220e43024665e0c0f163351f5846..168040da0b355047080e49ad57c9c65e0fc5f512 100644 (file)
@@ -246,8 +246,9 @@ class SemanticScuttle_Service_Vote extends SemanticScuttle_DbService
         //update bookmark table
         $bm  = SemanticScuttle_Service_Factory::get('Bookmark');
         $res = $this->db->sql_query(
-            'UPDATE ' . $bm->getTableName()
+            $sql='UPDATE ' . $bm->getTableName()
             . ' SET bVoting = bVoting + ' . (int)$vote
+            . ' WHERE bId = ' . (int)$bookmark
         );
         $this->db->sql_freeresult($res);
 
@@ -267,7 +268,10 @@ class SemanticScuttle_Service_Vote extends SemanticScuttle_DbService
     {
         throw new Exception('Not implemented yet');
         //FIXME
-        //SELECT bid, SUM( vote ) FROM sc_votes GROUP BY bid
+        $bm  = SemanticScuttle_Service_Factory::get('Bookmark');
+        $sql = 'UPDATE ' . $bm->getTableName() . ' as B SET bVoting = '
+            . '(SELECT SUM(vote) FROM ' . $this->getTableName() . ' as V'
+            . ' WHERE V.bId = B.bId GROUP BY bid)';
     }