diff options
author | cweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f> | 2009-10-28 22:15:14 +0000 |
---|---|---|
committer | cweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f> | 2009-10-28 22:15:14 +0000 |
commit | bb5205053e9ae9e584df9715dafd85f9c576f248 (patch) | |
tree | 78cfab0b0f18d4593e0913ee893c4047dcebfb45 /src/SemanticScuttle/Service/Vote.php | |
parent | 03bc498effbd7d009cbfa15f765a8d4934e52ea1 (diff) | |
download | semanticscuttle-bb5205053e9ae9e584df9715dafd85f9c576f248.tar.gz semanticscuttle-bb5205053e9ae9e584df9715dafd85f9c576f248.tar.bz2 |
implement rewriteVotings() and unittest the method
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@448 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'src/SemanticScuttle/Service/Vote.php')
-rw-r--r-- | src/SemanticScuttle/Service/Vote.php | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/SemanticScuttle/Service/Vote.php b/src/SemanticScuttle/Service/Vote.php index 168040d..89088f0 100644 --- a/src/SemanticScuttle/Service/Vote.php +++ b/src/SemanticScuttle/Service/Vote.php @@ -261,17 +261,18 @@ class SemanticScuttle_Service_Vote extends SemanticScuttle_DbService * Re-calculates all votings for all bookmarks * and updates the voting values in the bookmarks * table. + * This is mainly meant to be an administrative method + * to fix a broken database. * * @return void */ public function rewriteVotings() { - throw new Exception('Not implemented yet'); - //FIXME - $bm = SemanticScuttle_Service_Factory::get('Bookmark'); - $sql = 'UPDATE ' . $bm->getTableName() . ' as B SET bVoting = ' + $bm = SemanticScuttle_Service_Factory::get('Bookmark'); + $query = 'UPDATE ' . $bm->getTableName() . ' as B SET bVoting = ' . '(SELECT SUM(vote) FROM ' . $this->getTableName() . ' as V' . ' WHERE V.bId = B.bId GROUP BY bid)'; + $this->db->sql_query($query); } |