1
2
3
4
5
6
7
8
9
10
11
12
sub get_hasharray{
my ($statement, @param) = @_;
my $sth = $dbh->prepare($statement);
$sth->execute(@param) or die failLog( $dbh->errstr );
my @erg;
while (my $zeile = $sth->fetchrow_hashref()){
push(@erg,$zeile);
}
$sth->finish;
return @erg;
}
my @table = WebDB::get_hasharray("SELECT FACH, STELLPLATZ_IDENT, EBENE, STATIONS_IDENT, BE_IDENT, SPUR FROM FCT_WT_SPUREN ORDER BY BE_IDENT");
$sth->fetchrow_array
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
sub get_orderdarray{ my ($statement, $order, @param) = @_; my $sth = $dbh->prepare($statement); $sth->execute(@param) or die failLog( $dbh->errstr ); my @erg; while (my $zeile = $sth->fetchrow_hashyref()) { my @ret; push(@ret,[$_,$zeile->{$_}]) for(@$order); push(@erg,\@ret); } $sth->finish; return @erg; }
1 2 3 4 5 6 7 8 9 10 11
my @table = WebDB::get_hasharray( "SELECT * FROM FCT_WT_SPUREN ORDER BY BE_IDENT", [qw( FACH STELLPLATZ_IDENT EBENE STATIONS_IDENT BE_IDENT SPUR )] );
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
@table =
(
[
['FACH',1],
['STELLPLATZ_IDENT',1],
['EBENE',1],
['STATIONS_IDENT',1],
['BE_IDENT',1],
['SPUR',1],
],
[
['FACH',2],
['STELLPLATZ_IDENT',2],
['EBENE',2],
['STATIONS_IDENT',2],
['BE_IDENT',2],
['SPUR',2],
],
...
)
1 2 3 4 5
print join( " : " , @{$sth->{NAME}}) , "\n"; while ( my @row = $sth->fetchrow_array ) { print join( " : " , @row ) , "\n"; }
1 2
my $ref = $STH->fetchall_arrayref({}); my $ref = $DBH->selectall_arrayref($statement, {Slice=>{}});