Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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."
"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!

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2023-03-25 16:23 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (63 votes). Check out past polls.