use the rowsPerPage option to getMatchingAssets as a limit clause when

usePaginator is not used.
This commit is contained in:
Colin Kuskie 2009-04-20 18:20:27 +00:00
parent adc6f803e6
commit 12acce6c57

View file

@ -277,11 +277,7 @@ Instead of returning an array reference of assetId's, return a paginator object.
=head3 rowsPerPage =head3 rowsPerPage
If usePaginator is passed, then this variable will set the number of rows per page that the paginator uses. If usePaginator is passed, then this variable will set the number of rows per page that the paginator uses.
If usePaginator is not passed, then this variable will limit the number of assetIds that are returned.
=head3 limit
Limit the number of assetIds that are returned. This should not be used in conjunction
with usePaginator.
=cut =cut
@ -333,15 +329,15 @@ sub getMatchingAssets {
my $query = 'select distinct assetKeyword.assetId from assetKeyword left join asset using (assetId) my $query = 'select distinct assetKeyword.assetId from assetKeyword left join asset using (assetId)
where '.join(' and ', @clauses).' order by creationDate desc, lineage'; where '.join(' and ', @clauses).' order by creationDate desc, lineage';
if ($options->{limit}) {
$query .= ' limit '. $options->{limit};
}
# perform the search # perform the search
if ($options->{usePaginator}) { if ($options->{usePaginator}) {
my $p = WebGUI::Paginator->new($self->session, undef, $options->{rowsPerPage}); my $p = WebGUI::Paginator->new($self->session, undef, $options->{rowsPerPage});
$p->setDataByQuery($query, undef, undef, \@params); $p->setDataByQuery($query, undef, undef, \@params);
return $p; return $p;
} }
elsif ($options->{rowsPerPage}) {
$query .= ' limit '. $options->{rowsPerPage};
}
return $self->session->db->buildArrayRef($query, \@params); return $self->session->db->buildArrayRef($query, \@params);
} }