NAME
DBIx::EAV::Cursor - Represents a query used for fetching entities.
SYNOPSIS
# get cursor from resultset
my $cursor = $eav->resultset('CD')->search(\%query)->cursor;
while (my $cd = $cursor->next) {
# $cd is the raw hashref returned from database
printf "CD id: %d\n", $cd->{id};
}
DESCRIPTION
A cursor is used to build, execute and iterate over a SQL query for the entities table. A a cursor instance is returned from find and from get (when you get() related data). You will never need to create a instance of this class yourself.
METHODS
all
- Arguments: none
- Return Value: @entities
Returns all entities in the result.
next
- Arguments: none
- Return Value: $result | undef
Returns the next element in the resultset (undef
if there is none).
Can be used to efficiently iterate over records in the resultset:
my $cursor = $eav->resultset('CD')->find;
while (my $cd = $cursor->next) {
print $cd->get('title');
}
Note that you need to store the cursor object, and call next
on it. Calling resultset('CD')->next
repeatedly will always return the first record from the cursor.
first
- Arguments: none
- Return Value: $result | undef
Resets the cursor (causing a fresh query to storage) and returns an object for the first result (or undef
if the resultset is empty).
reset
Deletes the current statement handle, if any. Next data fetching will trigger a new database query.
LICENSE
Copyright (C) Carlos Fernando Avila Gratz.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
AUTHOR
Carlos Fernando Avila Gratz <cafe@kreato.com.br>