Class::DBI::Iterator(3pm)

Class::DBI::Iterator3pm

Iterate over class::dbi search results

Usage

        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;

Overview

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.

Releases

11 releases since Debian 3.1 (Sarge); the text changed 6 times.

  1. 3.1
  2. 4.0
  3. 5.0
  4. 6.0
  5. 7–10
  6. 11
  7. 12–13

From libclass-dbi-perl 3.0.17-5 in Debian 13 (Trixie). Parsed by carta from the page's man source.