From 2b664a1f4dd6615a44d6b6aeafca35dc7c6c7984 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 2 Feb 2007 10:31:29 +0000 Subject: [PATCH] Eine weitere Datenbankhilfsfunktion eingebaut. --- SL/DBUtils.pm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/SL/DBUtils.pm b/SL/DBUtils.pm index 05837b577..996add880 100644 --- a/SL/DBUtils.pm +++ b/SL/DBUtils.pm @@ -3,7 +3,7 @@ package SL::DBUtils; require Exporter; @ISA = qw(Exporter); -@EXPORT = qw(conv_i conv_date do_query dump_query); +@EXPORT = qw(conv_i conv_date do_query selectrow_query dump_query); sub conv_i { my ($value, $default) = @_; @@ -26,6 +26,20 @@ sub do_query { } } +sub selectrow_query { + my ($form, $dbh, $query) = splice(@_, 0, 3); + + if (0 == scalar(@_)) { + my @results = $dbh->selectrow_array($query); + $form->dberror($query) if ($dbh->err); + return @results; + } else { + my @results = $dbh->selectrow_array($query, undef, @_); + $form->dberror($query . " (" . join(", ", @_) . ")") if ($dbh->err); + return @results; + } +} + sub dump_query { my ($level, $msg, $query) = splice(@_, 0, 3); while ($query =~ /\?/) { -- 2.20.1