Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
The stupid question is the question not asked
 
PerlMonks  

Re: Fetchrow_hash/array question with DBI/Perl

by dbwiz (Curate)
on Mar 20, 2004 at 16:15 UTC ( [id://338366]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


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 16: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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://338366]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.