View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Luke Reeves > DBI-ResultPager-0.9.2 > DBI::ResultPager



Annotate this POD

View/Report Bugs
Module Version: 0.9.2   Source  


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


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

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

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

 sub linkISBN {
     my($isbn) = shift;
     return '<a href="' .
         $isbn . '">ISBNdb</a>';

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

 # Set the number of results per page:

 # Vertically align the outputted columns:

 # Get the outputted table as a scalar
 my $output = $rp->getOutput();


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.



This sets the DBI database handle for query execution.

addColumnFormatter (name, formatter)

Adds a custom formatting routine to a column. When a row of that column is rendered, the customer format routine is called with two parameters - the value of the data in that cell, and a list reference containing the current row of the resultset. The list reference is useful for referring to other elements in the current row.


The source for this project should always be available from CPAN. Other than that it may be found at


        Original code:          Luke Reeves <>


Copyright (c) 2005 Luke Reeves <>

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


 Luke Reeves <>


perl(1), DBI(3).

syntax highlighting: