Added setDataByQuery method for paginating arbitrary data sets.

This commit is contained in:
JT Smith 2002-11-09 21:30:47 +00:00
parent 2d628a976f
commit 3fd2021b86

View file

@ -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;