Commit | Line | Data |
5cf243f6 |
1 | package DBIx::Class::Cursor; |
1923c0b4 |
2 | |
3 | use strict; |
4 | use warnings; |
1923c0b4 |
5 | |
5cf243f6 |
6 | =head1 NAME |
7 | |
8 | DBIx::Class::Cursor - Abstract object representing a query cursor on a |
9 | resultset. |
10 | |
11 | =head1 SYNOPSIS |
12 | |
13 | my $cursor = $schema->resultset('CD')->cursor(); |
14 | my $first_cd = $cursor->next; |
15 | |
16 | =head1 DESCRIPTION |
17 | |
18 | A Cursor represents a query cursor on a L<DBIx::Class::ResultSet> object. It |
19 | allows for traversing the result set with L</next>, retrieving all results with |
20 | L</all> and resetting the cursor with L</reset>. |
21 | |
22 | Usually, you would use the cursor methods built into L<DBIx::Class::ResultSet> |
23 | to traverse it. See L<DBIx::Class::ResultSet/next>, |
24 | L<DBIx::Class::ResultSet/reset> and L<DBIx::Class::ResultSet/all> for more |
25 | information. |
26 | |
27 | =head1 METHODS |
28 | |
29 | =head2 new |
30 | |
31 | =back |
32 | |
33 | Virtual method. Returns a new L<DBIx::Class::Cursor> object. |
34 | |
35 | =cut |
36 | |
1923c0b4 |
37 | sub new { |
28927b50 |
38 | die "Virtual method!"; |
1923c0b4 |
39 | } |
40 | |
5cf243f6 |
41 | =head2 next |
42 | |
43 | =back |
44 | |
8e23eaf2 |
45 | Virtual method. Advances the cursor to the next row. |
5cf243f6 |
46 | |
47 | =cut |
48 | |
1923c0b4 |
49 | sub next { |
28927b50 |
50 | die "Virtual method!"; |
1923c0b4 |
51 | } |
52 | |
5cf243f6 |
53 | =head2 reset |
54 | |
55 | =back |
56 | |
57 | Virtual method. Resets the cursor to the beginning. |
58 | |
59 | =cut |
60 | |
1923c0b4 |
61 | sub reset { |
28927b50 |
62 | die "Virtual method!"; |
1909f72b |
63 | } |
64 | |
5cf243f6 |
65 | =head2 all |
66 | |
67 | =back |
68 | |
8e23eaf2 |
69 | Virtual method. Returns all rows in the L<DBIx::Class::ResultSet>. |
5cf243f6 |
70 | |
71 | =cut |
72 | |
1a14aa3f |
73 | sub 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 |
84 | 1; |