NAME
SQL::DB::Cursor - SQL::DB database cursor
SYNOPSIS
use SQL::DB::Cursor;
my $cursor = SQL::DB::Cursor->new(
sth => $sth,
db => $sqldb,
query => $expr,
);
while (my $next = $cursor->next) {
print $next->column()
}
# Or if you want you can get all at once:
my @objects = $cursor->all;
DESCRIPTION
SQL::DB::Cursor is a Perl-side cursor/read-only ORM interface to DBI. It is used by SQL::DB to create objects from rows. See the SQL::DB "fetch()" method for details.
CONSTRUCTOR
- new(sth => $sth, db => $db, query => $expr)
-
Create a new cursor object. $sth is a DBI statement handle (ie the result of a DBI->execute call). $db is the SQL::DB object creating the cursor. $expr must be the SQL::DB::Expr which was used to create $sth.
ATTRIBUTES
- sth
-
The DBI statement handle.
- db
-
The SQL::DB object that created the statement handle and query.
- query
-
The SQL::DB::Expr used to create the statement handle.
- class
-
The class into which retrieved objects are blessed into. This is automatically created from the first row retrieved.
- done
-
Boolean value that is set to true when there are no more rows to be returned.
METHODS
- next
-
Returns the next row from the statement handle as an object. Returns undef when no data is left. Croaks on failure.
- all
-
Returns all rows from the statement handle as a list of objects. Returns the empty list if no data is available (or has already been fetch with 'next' for example). Croaks on failure.
- finish
-
Calls finish() on the DBI statement handle.
AUTHOR
Mark Lawrence <nomad@null.net>
COPYRIGHT AND LICENSE
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.