From 188696a433d68ae7e7546086a4491cdd377d3264 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Fri, 5 Sep 2014 13:53:31 +0200 Subject: [PATCH] DBUtils: selectall_ids --- SL/DBUtils.pm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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); -- 2.20.1