| 1 | package DBIx::Otogiri::Iterator; | ||||||||||
| 2 | 15 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 15 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 15 | ▶ | use Class::Accessor::Lite ( | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 15 | new => 0, | |||||||||
| 6 | ro => [qw/db sql binds table/], | ||||||||||
| 7 | rw => [qw/sth fetched_count/], | ||||||||||
| 8 | 15 | ); | |||||||||
| 9 | |||||||||||
| 10 | 2 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 11 | 2 | my ($class, %opts) = @_; | |||||||||
| 12 | 2 | $opts{sth} = $opts{db}->dbh->prepare($opts{sql}); | |||||||||
| 13 | 2 | ▶ | $opts{sth}->execute($opts{binds} ? @{$opts{binds}} : ()); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 14 | 2 | $opts{fetched_count} = 0; | |||||||||
| 15 | 2 | bless {%opts}, $class; | |||||||||
| 16 | } | ||||||||||
| 17 | |||||||||||
| 18 | 6 | ▶ | sub next { | ||||||||
|
Subroutine
next: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 19 | 6 | my $self = shift; | |||||||||
| 20 | 6 | my $row = $self->sth->fetchrow_hashref; | |||||||||
| 21 | 6 | ▶ | unless ($row) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | 2 | $self->sth->finish; | |||||||||
| 23 | 2 | $self->{sth} = undef; | |||||||||
| 24 | 2 | return; | |||||||||
| 25 | } | ||||||||||
| 26 | 4 | $self->{fetched_count}++; | |||||||||
| 27 | 4 | ($row) = $self->db->_inflate_rows($self->table, $row); | |||||||||
| 28 | 4 | return $row; | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 15 | 1; | |||||||||
| 32 | __END__ | ||||||||||