NAME
DBIx::Thin::Iterator - A base iteration class for DBIx::Thin
SYNOPSIS
my $iterator = Your::Model->find_all('user', {});
$iterator->size; # get row counts
my $row = $iterator->first; # get first row
$iterator->reset; # reset itarator potision
my @rows = $iterator->as_array; # get all rows as array
# iteration
while (my $row = $iterator->next) {
...
}
CLASS METHODS
new(%)
new
create(%)
Creates an instance of suitable DBIx::Thin::Iterator subclass.
Parameters:
sth: DBI sth object. L<DBIx::Thin::Iterator::StatementHandle>
data: Arrayref data. L<DBIx::Thin::Iterator::Arrayref>
object_class: A class for each row object
INSTANCE METHODS
first
Returns the first object.
next
Returns the next object.
reset
Rest current cursor position.
size
Returns containg object row num.
as_array
Converts the iterator to array data.
as_data_array
Converts the iterator to array data contains hashref (not object).
create_object
Creates an instance for 'object_class' when next is called.