SQL::DB::Iter - SQL::DB database iterator
0.971.2. Development release.
use SQL::DB::Iter; my $iter = SQL::DB::Iter->new( sth => $sth, ); while (my $row = $iter->next) { print $row->column(), $row->some_other_column; } # Or if you want you can get everything at once: my @rows = $iter->all;
SQL::DB::Iter is a class for traversing over records retrieved from a DBI statement handle. Note that this is a Perl-side iterator, completely unrelated to any database-side cursors.
The objects returned by the 'next' and 'all' methods are simple array-ref based objects with one accessor/modifer method per column. Method names are column names with spaces replaced by a '_'.
Returns a new iterator object. $sth must be a DBI statement handle that has already been 'executed'.
The DBI statement handle. Read-only.
The class name into which retrieved rows are 'blessed'. This is automatically calculated based on the retrieved column names. Read-only.
Internal method.
Returns the next row from the statement handle as an object. Returns undef when there is no more data.
Returns all remaining rows from the statement handle as a list of objects. Returns the empty list if no data is available.
Returns the next row from the statement handle as a reference to a hash. Returns undef when there is no more data.
Returns all remaining rows from the statement handle as a list of references to hashes. Returns the empty list if no data is available.
Returns the next row from the statement handle as a reference to an array. Returns undef when there is no more data.
Returns all remaining rows from the statement handle as a list of references to arrays. Returns the empty list if no data is available.
Calls finish() on the DBI statement handle and internally records that there is no more data to be retrieved. This method is automatically called when the iterator object goes out of scope, so be aware you cannot use the passed-in statement handle again.
DBI, SQL::DB
Mark Lawrence <nomad@null.net>
Copyright (C) 2007-2011 Mark Lawrence <nomad@null.net>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
To install SQL::DB, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SQL::DB
CPAN shell
perl -MCPAN -e shell install SQL::DB
For more information on module installation, please visit the detailed CPAN module installation guide.