From: Moritz Bunkus Date: Fri, 2 Feb 2007 10:31:29 +0000 (+0000) Subject: Eine weitere Datenbankhilfsfunktion eingebaut. X-Git-Tag: release-2.4.2~174 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=2b664a1f4dd6615a44d6b6aeafca35dc7c6c7984;p=kivitendo-erp.git Eine weitere Datenbankhilfsfunktion eingebaut. --- 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 =~ /\?/) {