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

wigs at stirfried.org wigs at stirfried.org
Thu Jul 16 23:50:35 PDT 2009

On Fri, Jul 17, 2009 at 04:45:18PM +1000, 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.

This approach is also more resilient on those occasions that you have
done a 'SELECT *', and someone then goes and changes the underlaying
table schema by reordering or adding new rows.  If you fetch the rows
by array your code suddenly breaks at that point, often silently.


More information about the Melbourne-pm mailing list