On Fri, Nov 02, 2001 at 02:18:15PM +0100, Bart Lateur wrote:
> On Fri, 02 Nov 2001 07:27:49 -0500, Scott R. Godin wrote:
> 
> >    my %db;
> >    $sth->bind_columns( \( @db{ @{ $sth->{NAME} } } ));# magic
> >
> >    while ($sth->fetch)
> >    {
> >        #... and no worries about which order the columns get returned in
> >        #... since you access them via the $db{ColumnName} method :)
> 
> What's the advantage of this approach over
> 
>       while(my $db = fetchrow_hashref) {
>           ...
>       }
> 
> and accessing the datae through $db->{ColumnName}?

Speed! It's many times faster (assuming the loop is empty :)

(But use $sth->{NAME_lc} or $sth->{NAME_uc} for portability.

Tim.

Reply via email to