slayer has asked for the wisdom of the Perl Monks concerning the following question:
Oh great monks,
I'm going round in circles on this one. Essentially I want to extract a row from a mysql database, using fetchrow_hashref, but keep the columns in the SAME ORDER as the sql statement. The returned hash seems to be in a completely random order.
I've tried:
- Tie a hash, create a reference, then extract the data into that reference:
my (%row_hash,$row_hash); tie %row_hash, "Tie::IxHash"; my $row_hash = \%row_hash; while ($row_hash = $sth->fetchrow_hashref) {...
->This still jumbles the order of the returned hash.
- Tie a hash and extract straight in to that hash:
while (%row_hash = %{$sth->fetchrow_hashref}) {
->This returns a 'Can't use an undefined value as a HASH reference' error
- Extract the data into a reference, then tie the hash.
->The data is already jumbled and it is too late.
- Alter CPANs DBI sub fetchrow_hashref to tie the hash before returning it.
->Am incapable. DBI.c seems to order the rows fine...
Anymore suggestions would be greatfully received,
Cheers!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Ordering return from fetchrow_hashref
by gmax (Abbot) on Mar 02, 2004 at 17:18 UTC | |
Re: Ordering return from fetchrow_hashref ({NAME})
by tye (Sage) on Mar 02, 2004 at 15:54 UTC | |
Re: Ordering return from fetchrow_hashref
by eric256 (Parson) on Mar 02, 2004 at 15:50 UTC | |
Re: Ordering return from fetchrow_hashref
by rdfield (Priest) on Mar 02, 2004 at 15:52 UTC | |
Re: Ordering return from fetchrow_hashref
by slayer (Initiate) on Mar 04, 2004 at 16:44 UTC | |
by fiasudeen (Initiate) on Sep 02, 2014 at 19:31 UTC |
Back to
Seekers of Perl Wisdom