# 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) {
$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;
}
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;
}
#####
-# 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) {
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) = (".","..","../..");