DBIx::Pager - SQL paging helper.
use DBIx::Pager; my $pager = DBIx::Pager->new( dsn => 'dbi:mysql:test', user => 'root', table => 'table', offset => 0, limit => 20 ); if($pager->has_next) { # ... }
DBIx::Pager supports calculation about paging when SELECT a lot of data. this module is suitable for Web application using MySQL and Template-Toolkit.
construct DBIx::Pager object. the optios are below.
DBI datasource.
DBI username
DBI password
connected database handle.
setup table name. (require)
limit of data per page. (require)
offset of page. (default 0)
SQL where clause.
my $pager = DBIx::Pager->new( dbh => $dbh table => 'table', offset => 0, limit => 20, where_clause => 'WHERE id < 1000' ); # with place holder. my $pager = DBIx::Pager->new( dbh => $dbh table => 'table', offset => 0, limit => 20, where_clause => [ 'WHERE id < ?', $id ] );
total count of rows.
return true when pager has next pages.
return true when pager has previous pages.
return next offset.
return previous offset.
return total "page" count.
reutrn current page number. first is 1.
IKEBE Tomohiro <ikebe@edge.co.jp>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Data::Page DBI
To install DBIx::Pager, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::Pager
CPAN shell
perl -MCPAN -e shell install DBIx::Pager
For more information on module installation, please visit the detailed CPAN module installation guide.