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  ?

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