NAME

DBIx::Fast::Result - Lightweight row iterator for query results

SYNOPSIS

my $rs = $db->query('SELECT id, name FROM users WHERE active = ?', 1);

while (my $row = $rs->hash) {
    say "$row->{id}: $row->{name}";
}

# Or fetch remaining rows at once
my $rs2 = $db->query('SELECT id FROM products LIMIT 100');
my $all = $rs2->all;

# Or as a flat list of single-column values
my $rs3 = $db->query('SELECT email FROM users');
my $emails = $rs3->flat;

DESCRIPTION

A thin wrapper around a DBI statement handle that provides convenient iterator methods. Created by "query" in DBIx::Fast::SQL and automatically finishes the statement handle when the object goes out of scope.

METHODS

hash

while (my $row = $rs->hash) { ... }

Returns the next row as a hashref, or undef when exhausted.

array

while (my $row = $rs->array) { ... }

Returns the next row as an arrayref, or undef when exhausted.

all

my $rows = $rs->all;

Returns all remaining rows as an arrayref of hashrefs.

flat

my $vals = $rs->flat;

Returns all remaining values from the first column as an arrayref.

count

my $n = $rs->count;

Returns the number of rows fetched so far.

finish

$rs->finish;

Explicitly finishes the statement handle. Called automatically on object destruction.

AUTHOR

SeHarrys

LICENSE

This is free software under the Artistic License 2.0.