NAME
DBIx::QueryByName::Result::HashIterator - A hash iterator around a statement handle
DESCRIPTION
Provides an iterator-like api to a DBI statement handle that is expected to return one or more columns upon each call to fetchrow_array().
DO NOT USE DIRECTLY!
INTERFACE
my $i = new($query,$sth);
-
Return a hash iterator wrapped around this statement handle.
my $result = $i->next();
-
or
my $result = $i->next($col1, $col2...);
-
If
next
is called with no arguments, it returns the query's result as a hashref (just asfetchrow_hash
would) or undef if there are no more rows to fetch.Example:
# call query GetJobs that returns an iterator on which
# we call next directly. The query returns a hash with
# two keys 'id' and 'name'
my
$v
=
$dbh
->GetJobs->
next
;
my
$id
=
$v
->{id};
my
$name
=
$v
->{name};
If
next
is called a list of column names in arguments, it returns the query's result as a list of the corresponding hashref's values for those columns, or undef if there are no more rows to fetch.Example:
# same as previous example, just more concise:
my
(
$id
,
$name
) =
$dbh
->GetJobs->
next
(
'id'
,
'name'
);