info > Class::DBI::Iterator

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

📖 NAME

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

🚀 Quick Reference

Use CaseCommandDescription
🔍 Searchingmy $it = My::Class->search(...)Execute search in scalar context to get an iterator
🔢 Counting$it->countGet the number of results
🏁 First result$it->firstRetrieve the first result
🔄 Iteratingwhile ($it->next) { ... }Loop through results one at a time
✂️ Slicing$it->slice(10,19)Get a range of results (list or arrayref)
🔄 Reset$it->resetReset the iterator to the beginning
🗑️ Delete all$it->delete_allDelete all results from the database

🔍 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.

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

Generated by phpman v4.9.26-5-g7740029 Author: Che Dong Under GNU General Public License
2026-08-14 21:13 @2600:1f28:365:80b0:4d23:66fa:c2bb:7bae
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Valid XHTML 1.0 Transitional!Valid CSS!