Freeside:3:Documentation:Developer/FS/PagedSearch

From Freeside
< Freeside:3:Documentation:Developer‎ | FS
Revision as of 13:36, 27 June 2014 by Jeremyd (talk | contribs) (Edit via perl MediaWiki framework (1.13))

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

NAME

FS::PagedSearch - Iterator for querying large data sets

SYNOPSIS

use FS::PagedSearch qw(psearch);

my $search = psearch('table', { field => 'value' ... }); $search->limit(100); #optional while ( my $row = $search->fetch ) { ... }

SUBROUTINES

psearch ARGUMENTS
A wrapper around FS::Record::qsearch. Accepts all the same arguments as qsearch, except for the arrayref union query mode, and returns an FS::PagedSearch object to access the rows of the query one at a time. If the query doesn't contain an ORDER BY clause already, it will be ordered by the table's primary key.

METHODS

fetch
Fetch the next row from the search results and remove it from the buffer. Returns undef if there are no more rows.
adjust ROWS
Add ROWS to the offset counter. This won't cause rows to be skipped in the current buffer but will affect the starting point of the next refill.
limit [ VALUE ]
Set/get the number of rows to retrieve per page. The default is 100.
increment [ VALUE ]
Set/get the number of rows to increment the offset for each row that's retrieved. Defaults to 1. If the rows are being modified in a way that removes them from the result set of the query, it's probably wise to set this to zero. Setting it to anything else is probably nonsense.
refill
Run the query, skipping a number of rows set by the row offset, and replace the contents of the buffer with the result. If there are no more rows, this will just empty the buffer. Called automatically as needed; don't call this from outside.

SEE ALSO

FS::Record

FS::Cursor is an eventual replacement for this.