Restore ability to handle underdefined root (t/prefetch/incomplete.t)
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Cursor.pm
CommitLineData
5cf243f6 1package DBIx::Class::Cursor;
1923c0b4 2
3use strict;
4use warnings;
1923c0b4 5
48a76fcf 6use base qw/DBIx::Class/;
7
5cf243f6 8=head1 NAME
9
10DBIx::Class::Cursor - Abstract object representing a query cursor on a
11resultset.
12
13=head1 SYNOPSIS
14
15 my $cursor = $schema->resultset('CD')->cursor();
c564f8c3 16
17 # raw values off the database handle in resultset columns/select order
18 my @next_cd_column_values = $cursor->next;
19
20 # list of all raw values as arrayrefs
21 my @all_cds_column_values = $cursor->all;
5cf243f6 22
23=head1 DESCRIPTION
24
25A Cursor represents a query cursor on a L<DBIx::Class::ResultSet> object. It
26allows for traversing the result set with L</next>, retrieving all results with
27L</all> and resetting the cursor with L</reset>.
28
29Usually, you would use the cursor methods built into L<DBIx::Class::ResultSet>
30to traverse it. See L<DBIx::Class::ResultSet/next>,
31L<DBIx::Class::ResultSet/reset> and L<DBIx::Class::ResultSet/all> for more
32information.
33
34=head1 METHODS
35
36=head2 new
37
5cf243f6 38Virtual method. Returns a new L<DBIx::Class::Cursor> object.
39
40=cut
41
1923c0b4 42sub new {
28927b50 43 die "Virtual method!";
1923c0b4 44}
45
5cf243f6 46=head2 next
47
685dad64 48Virtual method. Advances the cursor to the next row. Returns an array of
49column values (the result of L<DBI/fetchrow_array> method).
5cf243f6 50
51=cut
52
1923c0b4 53sub next {
28927b50 54 die "Virtual method!";
1923c0b4 55}
56
5cf243f6 57=head2 reset
58
5cf243f6 59Virtual method. Resets the cursor to the beginning.
60
61=cut
62
1923c0b4 63sub reset {
28927b50 64 die "Virtual method!";
1909f72b 65}
66
5cf243f6 67=head2 all
68
8e23eaf2 69Virtual method. Returns all rows in the L<DBIx::Class::ResultSet>.
5cf243f6 70
71=cut
72
1a14aa3f 73sub all {
74 my ($self) = @_;
75 $self->reset;
76 my @all;
77 while (my @row = $self->next) {
78 push(@all, \@row);
79 }
80 $self->reset;
81 return @all;
82}
83
1923c0b4 841;