in reply to Fetchrow_hash/array question with DBI/Perl

It isn't clear what you want to achieve.

If you want a list of arrays, then use

my $lol = $sth_m->fetchall_arrayref()
. If you want a list of hashes, then use
my $loh = $sth_m->fetchall_arrayref({});
(notice the empty hash ref passed as an argument).

In both cases, you get an array ref containing either hashes or arrays,a nd you can loop through the results.

Have a look at DBI Recipes for some more examples and explanations.

As a side note, you are using $results->{'company'}, but there is no 'company' column in your query.

Replies are listed 'Best First'.
Re: Re: Fetchrow_hash/array question with DBI/Perl
by perleager (Pilgrim) on Mar 20, 2004 at 21:56 UTC
    haha, yeah I did that to see how exactly the fetchrow_hashref worked. Even though I left it out of the sql query, it stil retrieved the value, which led me to think that fetchrow_hashref may retrieve all values in the table?

    Thanks, I got the script working with your example etcshadow. I guess I never knew about the "fetchall_hashref", instead I used fetchrow_hashref haha.

    Anthony