On Tue, Dec 11, 2001 at 04:15:42PM -0800, Matisse Enzer wrote:
> At 5:36 PM +0000 12/11/01, Tim Bunce wrote:
> >  >      my $sql = "SELECT name,address FROM $table WHERE zipcode=?";
> >>       my $found_rows = $wrapper->FetchAll("$sql","$zipcode");
> >>       # $found_rows is an array_ref of hash_refs
> >
> >Personally, I'd write
> >
> >     $found_rows = $dbh->selectall_arrayref($sql, { Slice => {} });
> >     # $found_rows is an array_ref of hash_refs
> 
> 
> Hmmm. Maybe you mean   selectall_hashref  ?

No. You maybe have an old version of the DBI.

See http://search.cpan.org/doc/TIMB/DBI-1.20/Changes

Tim.

> Or more likely, there is something about the   { Slice => {} } 
> construct which I am ignorant of.  It's a hash-ref with one slot, 
> 'Slice' and the value is an empty hash-ref, i see that much, but i 
> don't get the significance.
> 
> The code I have for for   FetchAll  is:
> 
> sub FetchAll {
>      my( $self, $sql, @bind_values ) = @_;
>      my $sth = $self->{'dbh'}->prepare($sql) or confess("SQL: {$sql}");
>      $sth->execute(@bind_values) or confess( "SQL: {$sql}");
>      my $rows = $sth->fetchw_hashref ) {
>          push( @rows, $row );
>      }
>      $sth->finish;
>      return \@rows;
> }
> 
> 
> which allows be to use   confess   in a couple places, which I don't 
> think i get with:
> 
> my $found_rows = $dbh->selectall_hashref($sql, { Slice => {} }, @bind_values);
> 
> Turning on DBI->trace might have the desired effect though... I need to check.
> -- 
> -------------------------------------------
> Matisse Enzer
> [EMAIL PROTECTED]
> http://www.matisse.net/

Reply via email to