Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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


Comment on Re: Re: DBI specification change
Select or Download Code

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 about the Monastery: (5)
As of 2014-12-22 00:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (109 votes), past polls