NAME

Class::DBI::PagedSearch - pageable results from searches

SYNOPSIS

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 });

DESCRIPTION

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.

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 })

DEFAULT SEARCH ATTRIBUTES

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:

__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.

BUGS

Please report any bugs you find via the CPAN RT system. http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Class-DBI-PagedSearch

AUTHOR EMERITUS

Chia-liang Kao clkao@clkao.org

AUTHOR

Fotango Ltd. cpan@fotango.com

If you're reporting bugs please use the RT system mentioned above so we can track the issues you report.

COPYRIGHT / LICENSE

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.