man > Class::DBI::Iterator

Class::DBI::Iterator(3pm) User Contributed Perl Documentation Class::DBI::Iterator(3pm)

📖 NAME

Class::DBI::Iterator - Iterate over Class::DBI search results

🚀 Quick Reference

Use CaseCommandDescription
Count results$it->countReturns the number of items in the result set
Get first result$it->firstReturns the first object from the iterator
Iterate through resultswhile ($it->next) { ... }Fetches and processes each result one at a time
Get a slice of results$it->slice(10,19)Returns a range of results (10th through 19th)
Reset iterator$it->resetResets the iterator to the beginning of the result set
Delete all results$it->delete_allDeletes all objects matched by the search

📝 SYNOPSIS

my $it = My::Class->search(foo => 'bar');

my $results = $it->count;

my $first_result = $it->first;
while ($it->next) { ... }

my @slice = $it->slice(10,19);
my $slice = $it->slice(10,19);

$it->reset;

$it->delete_all;

📚 DESCRIPTION

Any Class::DBI search (including a has_many method) which returns multiple objects can be made to return an iterator instead simply by executing the search in scalar context.

Then, rather than having to fetch all the results at the same time, you can fetch them one at a time, potentially saving a considerable amount of processing time and memory.

⚠️ CAVEAT

Note that there is no provision for the data changing (or even being deleted) in the database inbetween performing the search and retrieving the next result.


perl v5.32.0 2020-12-28 Class::DBI::Iterator(3pm)

Class::DBI::Iterator
📖 NAME 🚀 Quick Reference 📝 SYNOPSIS 📚 DESCRIPTION ⚠️ CAVEAT

Generated by phpman v4.10.0-7-g98e9fd5 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-08-31 08:26 @216.73.217.135
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!