1 package DBIx::Class::Pager;
11 DBIx::Class::Pager - Pagination of resultsets
17 This class lets you page through a resultset.
33 my ($criteria, $attr) = @_;
35 my $rows = $attr->{rows} || 10;
36 my $current = $attr->{page} || 1;
38 # count must not use LIMIT, so strip out rows/offset
39 delete $attr->{$_} for qw/rows offset/;
41 my $total = $self->count( $criteria, $attr );
42 my $page = Data::Page->new( $total, $rows, $current );
44 $attr->{rows} = $page->entries_per_page;
45 $attr->{offset} = $page->skipped;
47 my $iterator = $self->search( $criteria, $attr );
49 return ( $page, $iterator );
58 Andy Grundman <andy@hybridized.org>
62 You may distribute this code under the same terms as Perl itself.