From: Sven Schöling Date: Fri, 5 Sep 2014 11:53:31 +0000 (+0200) Subject: DBUtils: selectall_ids X-Git-Tag: release-3.2.0beta~179 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=188696a433d68ae7e7546086a4491cdd377d3264;p=kivitendo-erp.git DBUtils: selectall_ids --- diff --git a/SL/DBUtils.pm b/SL/DBUtils.pm index 2d9c472af..689340ac2 100644 --- a/SL/DBUtils.pm +++ b/SL/DBUtils.pm @@ -8,6 +8,7 @@ our @EXPORT = qw(conv_i conv_date conv_dateq do_query selectrow_query do_stateme selectfirst_hashref_query selectfirst_array_query selectall_hashref_query selectall_array_query selectall_as_map + selectall_ids prepare_execute_query prepare_query create_sort_spec does_table_exist add_token); @@ -236,6 +237,25 @@ sub selectall_as_map { return %hash; } +sub selectall_ids { + $main::lxdebug->enter_sub(2); + + my ($form, $dbh, $query, $key_col) = splice(@_, 0, 4); + + my $sth = prepare_execute_query($form, $dbh, $query, @_); + + my @ids; + while (my $ref = $sth->fetchrow_arrayref()) { + push @ids, $ref->[$key_col]; + } + + $sth->finish; + + $main::lxdebug->leave_sub(2); + + return @ids; +} + sub create_sort_spec { $main::lxdebug->enter_sub(2);