in reply to DBI hashref does not return data in order of query
Hashes are unordered. On the bright side, DBI provides an ordered list of field names: @{ $sth->{NAME} }
my @names = @{ $sth->{NAME} }; while ( my $row = $sth->fetchrow_hashref ) { my @ordered_values = @{$row}{@names}; ... }
is roughly equivalent to
while ( my $row = $sth->fetchrow_arrayref ) { my @ordered_values = @$row; ... }
Also see the FetchHashKeyName attribute.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: DBI hashref does not return data in order of query
by hallikpapa (Scribe) on Oct 23, 2007 at 03:10 UTC | |
by Tux (Canon) on Oct 23, 2007 at 06:17 UTC | |
|
Re^2: DBI hashref does not return data in order of query
by hallikpapa (Scribe) on Oct 28, 2007 at 22:03 UTC | |
by erix (Prior) on Oct 28, 2007 at 23:38 UTC | |
by hallikpapa (Scribe) on Oct 28, 2007 at 23:46 UTC | |
by erix (Prior) on Oct 29, 2007 at 01:05 UTC | |
by hallikpapa (Scribe) on Oct 29, 2007 at 03:51 UTC |