summaryrefslogtreecommitdiff
path: root/lib/VNDB/DB/VNList.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/VNDB/DB/VNList.pm')
-rw-r--r--lib/VNDB/DB/VNList.pm35
1 files changed, 34 insertions, 1 deletions
diff --git a/lib/VNDB/DB/VNList.pm b/lib/VNDB/DB/VNList.pm
index 40ff20c7..4120e775 100644
--- a/lib/VNDB/DB/VNList.pm
+++ b/lib/VNDB/DB/VNList.pm
@@ -6,7 +6,7 @@ use warnings;
use Exporter 'import';
-our @EXPORT = qw|dbVNListGet|;
+our @EXPORT = qw|dbVNListGet dbVNListAdd dbVNListDel|;
# %options->{ uid order char voted page results }
@@ -68,6 +68,39 @@ sub dbVNListGet {
}
+# %options->{ uid rid rstat vstat }
+sub dbVNListAdd {
+ my($self, %o) = @_;
+
+ my %s = (
+ defined $o{rstat} ? ( 'rstat = ?', $o{rstat} ) : (),
+ defined $o{vstat} ? ( 'vstat = ?', $o{vstat} ) : (),
+ );
+ $o{rstat}||=0;
+ $o{vstat}||=0;
+
+ $self->dbExec(
+ 'UPDATE rlists !H WHERE uid = ? AND rid IN(!l)',
+ \%s, $o{uid}, ref($o{rid}) eq 'ARRAY' ? $o{rid} : [ $o{rid} ]
+ )
+ ||
+ $self->dbExec(
+ 'INSERT INTO rlists (uid, rid, rstat, vstat) VALUES(!l)',
+ [@o{qw| uid rid rstat vstat |}]
+ );
+}
+
+
+# Arguments: uid, rid
+sub dbVNListDel {
+ my($self, $uid, $rid) = @_;
+ $self->dbExec(
+ 'DELETE FROM rlists WHERE uid = ? AND rid IN(!l)',
+ $uid, ref($rid) eq 'ARRAY' ? $rid : [ $rid ]
+ );
+}
+
+
1;