Class::DBI::PagedSearch - pageable results from searches
package MyClass; use base 'Class::DBI'; use Class::DBI::PagedSearch; # more setup of MyClass here. # meanwhile, elsewhere... package main; use Data::Page; # create a new pager object my $page = Data::Page->new(); # we want only 10 entries per page $page->entries_per_page(10); # get page number 4 $page->current_page(4); # MyClass isa Class::DBI object where MyClass->search( species => 'camel', { pager => $page });
Override Class::DBI::search to provide pagable results. An optional Data::Page object is passed in as the hash argument at the end of the option, and its total_entries attribute will be populated after the query.
total_entries
MyClass->search(%where, { order_by => '', pager => $page })
It also provides a method that allows paging raw sql queries. Use this instead of set_sql if you need paging.
MyClass->search_sql($sql, @arg, { pager => $page })
If your class has a class getter called default_search_attributes, this plugin will use the attributes defined there as default to search by. An example use of this can be:
default_search_attributes
__PACKAGE__->default_search_attributes( { order_by => ['created_datetime ASC'] } );
to ensure that all searches on this class will order the results ascendingly by created_datetime column. You can always override these defaults.
Please report any bugs you find via the CPAN RT system. http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Class-DBI-PagedSearch
Chia-liang Kao clkao@clkao.org
clkao@clkao.org
Fotango Ltd. cpan@fotango.com
cpan@fotango.com
If you're reporting bugs please use the RT system mentioned above so we can track the issues you report.
Copyright Fotango 2005-2006. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Class::DBI::PagedSQLSearch, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::DBI::PagedSQLSearch
CPAN shell
perl -MCPAN -e shell install Class::DBI::PagedSQLSearch
For more information on module installation, please visit the detailed CPAN module installation guide.