jason corbett wrote:
> Hello all. Can someone tell me what is the difference in the various
> ways to FETCH data from a database? I bought like 3 books and they
> don't really go in depth with the reasons why there are several of
> them, and what happens if you interchange them with different
> scenarios.    
> 

I assume you're talking about the DBI module. If not, ignore everything that
follows :~)

> Here are the ones that I am asking about:
> 
> Fetch
> Fetchrow
> Fetchrow_array
> fetchall_arrayref
> fetchrow_hashref

fetch and fetchrow are aliases for fetchrow_arrayref and fetchrow_array, and
you forgot fetchrow_hashref, as well as the database handle methods
selectrow_array, selectrow_arrayref, selectrow_hashref, selectall_arrayref,
selectall_hashref, and selectcol_arrayref.

They break down into families based on number of rows returned (one or all),
and type of return value (array, arrayref, or hashref)

I think that DBI implements everything in terms of fetchrow_arrayref, so the
other formats are just convenience for difference situations. Why you would
use one over the other depends on what the structure of your data is and
what the needs of your application are.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to