diff options
author | Yorhel <git@yorhel.nl> | 2010-12-20 19:30:21 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2010-12-20 19:30:21 +0100 |
commit | 5d39ff714a16df3e820f95a89ba4fd7d3c192141 (patch) | |
tree | fe59f26eb51bfeba45311274959d8fc2b6671c11 /lib/VNDB/DB/ULists.pm | |
parent | 725b626dddd1acd033f61a94712336142c733937 (diff) |
Added ability to batch-edit votes to /u+/votes
Diffstat (limited to 'lib/VNDB/DB/ULists.pm')
-rw-r--r-- | lib/VNDB/DB/ULists.pm | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/VNDB/DB/ULists.pm b/lib/VNDB/DB/ULists.pm index 27594a91..7c0d2660 100644 --- a/lib/VNDB/DB/ULists.pm +++ b/lib/VNDB/DB/ULists.pm @@ -251,14 +251,15 @@ sub dbVoteStats { # Adds a new vote or updates an existing one # Arguments: vid, uid, vote +# vid can be an arrayref only when the rows are already present, in which case an update is done sub dbVoteAdd { my($self, $vid, $uid, $vote) = @_; $self->dbExec(q| UPDATE votes SET vote = ? - WHERE vid = ? + WHERE vid IN(!l) AND uid = ?|, - $vote, $vid, $uid + $vote, ref($vid) ? $vid : [$vid], $uid ) || $self->dbExec(q| INSERT INTO votes (vid, uid, vote) @@ -269,10 +270,11 @@ sub dbVoteAdd { # Arguments: uid, vid +# vid can be an arrayref sub dbVoteDel { my($self, $uid, $vid) = @_; $self->dbExec('DELETE FROM votes !W', - { 'vid = ?' => $vid, 'uid = ?' => $uid } + { 'vid IN(!l)' => [ref($vid)?$vid:[$vid]], 'uid = ?' => $uid } ); } |