| 1 | package DBIx::QueryByName::Result::ScalarIterator; | ||||||||||
| 2 | 1 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use Data::Dumper; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use DBIx::QueryByName::Logger qw(get_logger); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use base qw( DBIx::QueryByName::Result::Iterator ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | |||||||||||
| 10 | |||||||||||
| 11 | 0 | ▶ | sub next { | ||||||||
|
Subroutine
next: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||
| 12 | 0 | my $self = shift; | |||||||||
| 13 | |||||||||||
| 14 | 0 | ▶ | $self->_finish_and_croak("next got unexpected arguments: ".Dumper(@_)) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | if (@_); | ||||||||||
| 16 | |||||||||||
| 17 | return undef | ||||||||||
| 18 | 0 | ▶ | if (!defined $self->{sth}); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | |||||||||||
| 20 | 0 | ▶ | if (my @values = $self->{sth}->fetchrow_array()) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | |||||||||||
| 22 | 0 | ▶ | $self->_finish_and_croak("query ".$self->{query}." returns more than 1 column per row. Got: ".Dumper(\@values)) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | if (scalar @values > 1); | ||||||||||
| 24 | |||||||||||
| 25 | 0 | return $values[0]; | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | # no more rows to fetch. | ||||||||||
| 29 | # TODO: handle specially if it was an error? | ||||||||||
| 30 | 0 | $self->{sth}->finish(); | |||||||||
| 31 | 0 | $self->{sth} = undef; | |||||||||
| 32 | 0 | return undef; | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 1 | 1; | |||||||||
| 36 | |||||||||||
| 37 | __END__ | ||||||||||