Class::...terator(3)
π Class::DBI::Iterator π
okay so this is the User Contributed Perl Documentation page for Class::DBI::Iterator, and itβs literally here to make iterating over your Class::DBI search results a whole vibe. β¨
πΈ NAME πΈ
Class::DBI::Iterator β iterate over Class::DBI search results. no cap, thatβs the whole name. π
π¦ 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 β¨
okay bestie, hereβs the tea: 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, instead of having to fetch all the results at the same time, you can fetch them one at a time. That can potentially save a considerable amount of processing time and memory. lowkey iconic. π₯
π CAVEAT π
note note note: there is no provision for the data changing (or even being deleted) in the database inbetween performing the search and retrieving the next result. like, none. so keep that in mind, fr fr. π
kisses and sparkles, this page comes from perl v5.42.0 and is dated 2011-04-08 ππ
π¦ where this page comes from
- opensuse-leap 16.0: perl-Class-DBI 3.0.17-bp160.1.10 Β· GPL-1.0+ or Artistic-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms