[Melbourne-pm] fetchrow_array() vs fetchrow_arrayref() WAS RE: Perl DBI reference recommendations

Craig Sanders cas at taz.net.au
Fri Jul 17 00:11:08 PDT 2009


On Fri, Jul 17, 2009 at 04:49:37PM +1000, Scott Penrose wrote:
> On 17/07/2009, at 4:45 PM, Craig Sanders wrote:
> >i tend to use fetchrow_hashref() or fetchall_hashref() - that way
> >i can use the sql column names to access the data and don't have
> >to guess which array element matches which field....and, more
> >importantly, don't have to renumber things when i add or remove a
> >field to the select.
>
> My fav is to use fetchall_arrayref({});
>
> The "{}" (empty hash) tells fetchall_arrayref to return a array ref
> of hash refs - all the advantages of the above, but returns it as an
> arrayref.

ah, that's neat.  didn't know that one.  thanks.

presumably it retains the order of records returned in the query, so
"order by" is actually useful (unlike with the _hashref methods which
are, obviously, un-ordered).

craig

-- 
craig sanders <cas at taz.net.au>

All the waters of the earth are in the armpit of the Great Frog.
		-- R. Crumb


More information about the Melbourne-pm mailing list