The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

DBI::ResultPager - creates an HTML-based pager for DBI result sets.

SYNOPSIS

 # Create a pageable result set
 use DBI::ResultPager;
 
 my $rp = DBI::ResultPager->new;
 $rp->dbh($dbh);
 $rp->query('select books.title, authors.name
             from books
             inner join (books.author_id = authors.id)');
 $rp->display();

 # The same result set, but sorted with nicer column headings
 my $rp = DBI::ResultPager->new;
 $rp->dbh($dbh);
 $rp->query('select books.title as "Title", 
             authors.name as "Author"
             from books
             inner join (books.author_id = authors.id)');
 $rp->defaultOrder('Title');
 $rp->display();

 # Adding a custom formatter to build links
 my $rp = DBI::ResultPager->new;
 $rp->dbh($dbh);
 $rp->query('select books.title as "Title", 
             books.isbn as "ISBN",
             authors.name as "Author"
             from books
             inner join (books.author_id = authors.id)');
 $rp->addColumnFormatter('ISBN', \&linkISBN);
 $rp->display();

 sub linkISBN {
     my($isbn) = shift;
     return '<a href="http://isbndb.com/search-all.html?kw=' .
         $isbn . '">ISBNdb</a>';
 }

 # Adding a custom column and hiding an identity column
 my $rp = DBI::ResultPager->new;
 $rp->dbh($dbh);
 $rp->query('select books.id,
             books.title as "Title", 
             from books');
 $rp->hideColumn('books.id');
 $rp->addCustomColumn('Functions', \&bookFunctions);
 $rp->display();
 
 sub bookFunctions {
   my (@row) = (@_);
   return '<a href="delete.cgi?id=' . $row[0] . '">delete</a>';
 }

 # Set the number of results per page:
 $rp->perPage(20);

DESCRIPTION

This class is a quick and easy method of paging result sets returned from the DBI database interface. It takes a standard SQL query along with a database handle and performs the query, inserting the resultant rows into a pageable HTML table. Various options such as sort order can be adjusted, and columns can have formatters attached. Columns can also be hidden, and custom columns can be added to the output.

METHODS

SOURCE AVAILABILITY

The source for this project should always be available from CPAN. Other than that it may be found at http://www.neuro-tech.net/.

AUTHOR

        Original code:          Luke Reeves <luke@neuro-tech.net>
                                http://www.neuro-tech.net/

COPYRIGHT

Copyright (c) 2005 Luke Reeves <luke@neuro-tech.net>

DBI::ResultPager is free software. You can redistribute it and/or modify it under the same terms as Perl itself.

CREDITS

 Luke Reeves <luke@neuro-tech.net>

SEE ALSO

perl(1), DBI(3).