From 3fd2021b86f004f7067c8fd7987e2edf72b21723 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Sat, 9 Nov 2002 21:30:47 +0000 Subject: [PATCH] Added setDataByQuery method for paginating arbitrary data sets. --- lib/WebGUI/Paginator.pm | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/WebGUI/Paginator.pm b/lib/WebGUI/Paginator.pm index a7e8d28ee..a4366fb7c 100644 --- a/lib/WebGUI/Paginator.pm +++ b/lib/WebGUI/Paginator.pm @@ -430,8 +430,27 @@ sub new { bless {_url => $currentURL, _rpp => $rowsPerPage, _rowRef => $rowRef, _pn => $formVar}, $class; } - - +#------------------------------------------------------------------- +sub setDataByQuery { + my ($sth, $pageCount, $rowCount, $dbh, $sql, $self, @row, $data); + ($self, $sql, $dbh) = @_; + $dbh |= $session{dbh}; + $sth = WebGUI::SQL->read($sql); + $pageCount = 1; + while ($data = $sth->hashRef) { + $rowCount++; + if ($rowCount/$self->{_rpp} > $pageCount) { + $pageCount++; + } + if ($pageCount == $self->getPageNumber) { + push(@row,$data); + } else { + push(@row,{}); + } + } + $sth->finish; + $self->{_rowRef} = \@row; +} 1;