Teng::Plugin::SQLPager - Paginate with SQL
package My::DB; use parent qw/Teng/; __PACKAGE__->load_plugin(qw/SQLPager/); # in your application $db->search_by_sql_with_pager( q{SELECT * FROM member ORDER BY id DESC}, [], {page => 1, rows => 20} );
This module searches database by SQL with paginate.
search_by_sql_with_pager method adds LIMIT clause automatically.
You can pass arguments as following.
$db->search_by_sql_with_pager($sql, $binds, $opt[, $table_name]);
This is a SQL statement in string.
This is a bind values in arrayref.
Options for search_by_sql_with_pager. Important options are 'page' and 'rows'.
page is a current page number. rows is a entries per page.
You can pass a table name.
This argument is optional. If you don't pass a table name, Teng guess table name automatically.
This module does not work with Oracle since Oracle does not support limit clause.
To install Teng, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Teng
CPAN shell
perl -MCPAN -e shell install Teng
For more information on module installation, please visit the detailed CPAN module installation guide.