]> git.donarmstrong.com Git - infobot.git/blobdiff - src/dbm.pl
save latest version
[infobot.git] / src / dbm.pl
index 63e6c81005c24dfa675759743aab3c6bdaeee1f0..0048143fa1ab457f03e6dc95d8c5a93a069b8615 100644 (file)
@@ -14,29 +14,37 @@ package main;
 use vars qw(%factoids %param);
 
 {
+    # FIXME we don't handle multiply indexes tables
+    # perhaps we should combine the keys with a ':' or something?
+    # the spaces below separate the keys from the rest
+    # of the fields.
+    # Tim Riker thinks that freshmeat below should be a single index
     my %formats = (
        'factoids', [
            'factoid_key',
-           'factoid_value',
+
+           'requested_by',
+           'requested_time',
+           'requested_count',
            'created_by',
            'created_time',
            'modified_by',
            'modified_time',
-           'requested_by',
-           'requested_time',
-           'requested_count',
            'locked_by',
-           'locked_time'
+           'locked_time',
+           'factoid_value'
        ],
        'freshmeat', [
            'projectname_short',
            'latest_version',
+
            'license',
            'url_homepage',
            'desc_short'
        ],
        'rootwarn', [
            'nick',
+
            'attempt',
            'time',
            'host',
@@ -44,19 +52,27 @@ use vars qw(%factoids %param);
        ],
        'seen', [
            'nick',
+
            'time',
            'channel',
            'host',
-           'messagecount',
-           'hehcount',
-           'karma',
            'message'
        ],
        'stats', [
            'nick',
            'type',
-           'counter',
-           'time'
+           'channel',
+
+           'time',
+           'counter'
+       ],
+       'botmail', [
+           'srcwho',
+           'dstwho',
+
+           'srcuh',
+           'time',
+           'msg'
        ]
     );
 
@@ -137,6 +153,8 @@ sub dbGet {
        return(@retval);
     }
 
+    # FIXME this should be in $select order
+    # and it's now in field order
     &DEBUG("dbGet: select=>'$select'.");
     my @array = split "$;", ${"$table"}{lc $val};
     unshift(@array,$val);
@@ -230,10 +248,12 @@ sub dbSetRow {
 }
 
 #####
-# Usage: &dbDel($table, $primkey, $primval, [$key]);
+# Usage: &dbDel($table, $primhash_ref);
+#  Note: dbDel does dbQuote
 sub dbDel {
-    my ($table, $primkey, $primval, $key) = @_;
-    &DEBUG("dbDel($table, $primkey, $primval);");
+    my ($table, $phref) = @_;
+    # FIXME does not really handle more than one key!
+    my $primval = join(':', values %{$phref});
 
     if (!defined ${$table}{lc $primval}) {
        &DEBUG("dbDel: lc $primval does not exist in $table.");
@@ -251,7 +271,7 @@ sub dbReplace {
     my ($table, $key, %hash) = @_;
     &DEBUG("dbReplace($table, $key, %hash);");
 
-    &dbDel($table, $key, $hash{$key}, %hash);
+    &dbDel($table, {$key=>$hash{$key}});
     &dbInsert($table, $hash{$key}, %hash);
     return 1;
 }