On Mon, Dec 10, 2001 at 11:45:16PM -0800, Matisse Enzer wrote:
> Hi folks.
> 
> I'm looking for feedback on this...
> 
> The source code is on my web site at:
>     http://www.matisse.net/perl-modules/DBI/Wrapper/
> 
> Here's the README:
> 
> DBI/Wrapper version 0.01
> ========================
> 
> DBI::Wrapper is a simple module that provides a high-level interface
> to the Perl DBI module. The provided methods are for fetching
> a single record (returns a hash-ref), many records (returns
> an array-ref of hash-refs), and for executing a non-select statement
> (returns a result code).
> 
> The intention here is that your application will have much cleaner 
> code, so instead of writing:
> 
>      my $sql = "SELECT name,address FROM $table WHERE zipcode=?";
>      my $sth = $dbh->prepare("SELECT name,address FROM $table WHERE zipcode=?");
>      my $rv  = $sth->execute("$zipcode");
>      my @found_rows;
>      while ( my $hash_ref = $sth->fetchrow_hashref ) {
>          push( @found_rows, $hash_ref );
>      }
> 
> You would write:
> 
>      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

No need for an extra module.

Tim.

Reply via email to