# phpman > man > Class::DBI::Iterator

## NAME
    [Class::DBI::Iterator](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3ADBI%3A%3AIterator/markdown) - Iterate over [Class::DBI](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3ADBI/markdown) search results

## SYNOPSIS
            my $it = [My::Class](https://www.chedong.com/phpMan.php/perldoc/My%3A%3AClass/markdown)->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](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3ADBI/markdown) 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.

