]> git.donarmstrong.com Git - infobot.git/blobdiff - src/db_mysql.pl
- renamed Factoids/Misc.pl to Factoids/Core.pl
[infobot.git] / src / db_mysql.pl
index 185a5bf5b521f5c591591637265dba598e204b78..cb7b136f8b4f3b7bee55797394a572c0e9b288d3 100644 (file)
@@ -46,7 +46,7 @@ sub dbQuote {
 # Usage: &dbGet($table, $select, $where);
 sub dbGet {
     my ($table, $select, $where) = @_;
-    my $query   = "SELECT $select FROM $table";
+    my $query  = "SELECT $select FROM $table";
     $query     .= " WHERE $where" if ($where);
 
     if (!defined $select) {
@@ -88,13 +88,10 @@ sub dbGetCol {
     $query     .= " WHERE ".$where if ($where);
     my %retval;
 
-    &DEBUG("dbGetCol: query => '$query'.");
-
     my $sth = $dbh->prepare($query);
     &SQLDebug($query);
     if (!$sth->execute) {
        &ERROR("GetCol: execute: '$query'");
-#      &ERROR("GetCol => $DBI::errstr");
        $sth->finish;
        return;
     }
@@ -148,10 +145,7 @@ sub dbGetColNiceHash {
        return;
     }
 
-    # todo: get column names, do $hash{$primkey}{blah} = ...
-    while (my @row = $sth->fetchrow_array) {
-       # reverse it to make it easier to count.
-    }
+    %retval = %{ $sth->fetchrow_hashref() };
 
     $sth->finish;
 
@@ -276,10 +270,10 @@ sub dbInsert {
 }
 
 #####
-# Usage: &dbReplace($table, %hash);
+# Usage: &dbReplace($table, $key, %hash);
 #  Note: dbReplace does optional dbQuote.
 sub dbReplace {
-    my ($table, %hash) = @_;
+    my ($table, $key, %hash) = @_;
     my (@keys, @vals);
 
     foreach (keys %hash) {
@@ -461,42 +455,6 @@ sub searchTable {
     return @results;
 }
 
-####################################################################
-##### Factoid related stuff...
-#####
-
-#####
-# Usage: &getFactInfo($faqtoid, type);
-#  Note: getFactInfo does dbQuote
-sub getFactInfo {
-    return &dbGet("factoids", $_[1], "factoid_key=".&dbQuote($_[0]) );
-}
-
-#####
-# Usage: &getFactoid($faqtoid);
-sub getFactoid {
-    return &getFactInfo($_[0], "factoid_value");
-}
-
-#####
-# Usage: &delFactoid($faqtoid);
-sub delFactoid {
-    my ($faqtoid) = @_;
-
-    &dbDel("factoids", "factoid_key",$faqtoid);
-    &status("DELETED '$faqtoid'");
-
-    return 1;
-}
-
-sub SQLDebug {
-    return unless (&IsParam("SQLDebug"));
-
-    return unless (fileno SQLDEBUG);
-
-    print SQLDEBUG $_[0]."\n";
-}
-
 sub dbCreateTable {
     my($table) = @_;
     my(@path)  = (".","..","../..");