Here's a response from Michael Cameron, which arrived on the
CGI::Application list. It provides the example I was looking for. Thanks!

  -mark 

-------- Original Message --------
From: "Michael Cameron" <[EMAIL PROTECTED]>
Subject: Re: [htmltmpl] Two HTML::Pager questions
To: <[EMAIL PROTECTED]>,<[EMAIL PROTECTED]>

Below was my first trial to do what you are talking about.  Haven't actually
used in production or really reviewed setup but it works.


 my $get_data = sub{
    my ($offset,$rows) = @_;

    my $query = "SELECT mortgage_id, first_name, last_name, started_date,
application_date, status, completed_date
                FROM person,mortgage
                WHERE primary_applicant = person_id limit $offset,$rows";
    my $sth = $self->param('dbh')->prepare($query);
       $sth->execute() || die $sth->errstr;

    my @array= ();

    while(my $row = $sth->fetchrow_hashref()){
                push @array,$row;
    }
        return \@array;
  };#end callback sub
  my $pager = HTML::Pager->new(
                                query=>$self->query(),
                                get_data_callback=>$get_data,
                                rows=>$rows,
                                page_size=>$self->param('page_size'),
                                template=>$template,
                                NEXT_LINK_TEXT=>'Next',
                                PREV_LINK_TEXT=>'Prev',
                                );

----- Original Message -----
From: "Mark Stosberg" <[EMAIL PROTECTED]>
To: "HTML-Template Mailing List" <[EMAIL PROTECTED]>
Sent: Tuesday, January 29, 2002 8:27 AM
Subject: [htmltmpl] Two HTML::Pager questions


>
> Hello,
>
> I have a couple of questions regarding the HTML::Pager module, which
> uses  HTML::Template:
>
> * Has anyone thought about recrafting this as a CGI::Application app?
>
> * From the documentation, it appears that the whole result set needs to
> be available even though I'm just displaying a subset of it. Is this
> correct? I think Postgres and MySQL now both support a better
> alternative using the "LIMIT" feature. I can run one SQL statement to
> find out that I would get back 2000 rows, and a second statement to get
> back only rows 10 through 20 of the result set. Does the current feature
> set support this model. If so,  could someone provide an example?
>
> Thanks,
>
>   -mark
>
>  . . . . . . . . . . . . . . . . . . . . . . . . . .
>    Mark Stosberg              Principal Developer
>    [EMAIL PROTECTED]       Summersault, LLC
>    765-939-9301 ext 223       website development
>  . . . . . http://www.summersault.com/ . . . . . . .
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to