Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Re: DBI specification change

by aufrank (Pilgrim)
on Jul 18, 2002 at 16:06 UTC ( #182879=note: print w/replies, xml ) Need Help??


in reply to Re: DBI specification change
in thread DBI specification change

this actually already exists and is very useful. the method you're looking for is fetchall_arrayref( {} )

from the docs:

"When passed a hash reference, fetchall_arrayref uses /fetchrow_hashref to fetch each row as a hash reference. If the parameter hash is empty then fetchrow_hashref is simply called in a tight loop and the keys in the hashes have whatever name lettercase is returned by default from fetchrow_hashref."
and
"To fetch all fields of every row as a hash ref:
$tbl_ary_ref = $sth->fetchall_arrayref({});  "

going through each row then looks something like:

foreach my $hashref_row (@$tbl_ary_ref) { foreach my $field (sort keys %$hashref_row) { my $value = $hashref_row->{$field}; } }

there's a good chance my use of references is off in the 3rd line, but at least I tried :)

hope that's what you were looking for!
--au

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://182879]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2016-10-01 19:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?






    Results (6 votes). Check out past polls.