As clear as it gets
[dbsrgits/DBIx-Class-Historic.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();
16 my $first_cd = $cursor->next;
17
18=head1 DESCRIPTION
19
20A Cursor represents a query cursor on a L<DBIx::Class::ResultSet> object. It
21allows for traversing the result set with L</next>, retrieving all results with
22L</all> and resetting the cursor with L</reset>.
23
24Usually, you would use the cursor methods built into L<DBIx::Class::ResultSet>
25to traverse it. See L<DBIx::Class::ResultSet/next>,
26L<DBIx::Class::ResultSet/reset> and L<DBIx::Class::ResultSet/all> for more
27information.
28
29=head1 METHODS
30
31=head2 new
32
5cf243f6 33Virtual method. Returns a new L<DBIx::Class::Cursor> object.
34
35=cut
36
1923c0b4 37sub new {
28927b50 38 die "Virtual method!";
1923c0b4 39}
40
5cf243f6 41=head2 next
42
685dad64 43Virtual method. Advances the cursor to the next row. Returns an array of
44column values (the result of L<DBI/fetchrow_array> method).
5cf243f6 45
46=cut
47
1923c0b4 48sub next {
28927b50 49 die "Virtual method!";
1923c0b4 50}
51
5cf243f6 52=head2 reset
53
5cf243f6 54Virtual method. Resets the cursor to the beginning.
55
56=cut
57
1923c0b4 58sub reset {
28927b50 59 die "Virtual method!";
1909f72b 60}
61
5cf243f6 62=head2 all
63
8e23eaf2 64Virtual method. Returns all rows in the L<DBIx::Class::ResultSet>.
5cf243f6 65
66=cut
67
1a14aa3f 68sub all {
69 my ($self) = @_;
70 $self->reset;
71 my @all;
72 while (my @row = $self->next) {
73 push(@all, \@row);
74 }
75 $self->reset;
76 return @all;
77}
78
1923c0b4 791;