The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Maptastic::DBI - a trivial little wrapper for a row iterator

SYNOPSIS

 use Maptastic::DBI;

 # the SQL statement (or DBI statement handle, if you prefer)
 # is the last argument
 my $ri = row_iter($dbh, $box, <<SQL);
 select item
 from   boxes
 where  box = ?
 SQL

 while ( my $row = $ri->() ) {
     #...
 }

 # you can also put items back
 $ri->($item);

 # With Maptastic, grab all the rows at once.
 use Maptastic;
 my @rows = slurp row_iter($dbh, $sql);

DESCRIPTION

This module contains a very simple wrapper for DBI calls, designed for fans of iterators. It just wraps the usual:

  my $sth = $dbh->prepare(<<SQL);
  select
     foo
  from
     bar
  where
     baz = ?
  SQL
  $sth->execute($baz);
  while (my $row = $sth->fetchrow_hashref) {

  }

into:

  my $ri = row_iter($dbh, $baz, <<SQL);
  while (my $row = $ri->()) {

  }

SEE ALSO

_Higher Order Perl_, Mark Jason Dominus.

AUTHOR AND LICENSE

Copyright (c) 2007, Catalyst IT (NZ) Ltd. All rights reserved. This program is free software; you may use it, and/or distribute it under the same terms as Perl itself.