Added setDataByQuery method for paginating arbitrary data sets.
This commit is contained in:
parent
2d628a976f
commit
3fd2021b86
1 changed files with 21 additions and 2 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue