Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^3: Populating an array from a mysql select

by Errto (Vicar)
on May 04, 2007 at 18:44 UTC ( [id://613634]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Populating an array from a mysql select
in thread Populating an array from a mysql select

The reason is in what fetchall_arrayref returns. In general an SQL statement car return many columns, so you get array of rows, not an array of values. Each row in turn is an array ref or hash ref depending on how you call fetchrow_arrayref. In your case, you only have one column, and you can use fetchcol_arrayref to obtain that one column's data directly without havning to dereference anything for each row.

Update: I misremembered the existence of a fetchcol_arrayref method. No such method exists; I was thinking of selectcol_arrayref which operates on a dbh, not a sth, and takes a statement as its first argument.

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2024-04-19 09:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found