| 1 | package DBIx::QueryByName::Result::HashIterator; | ||||||||||
| 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 | 0 | ▶ | sub next { | ||||||||
|
Subroutine
next: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||
| 10 | 0 | my $self = shift; | |||||||||
| 11 | |||||||||||
| 12 | 0 | my @columns = @_; | |||||||||
| 13 | |||||||||||
| 14 | return undef | ||||||||||
| 15 | 0 | ▶ | if (!defined $self->{sth}); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | |||||||||||
| 17 | 0 | ▶ | if (my $hash = $self->{sth}->fetchrow_hashref()) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | |||||||||||
| 19 | 0 | ▶ | return $hash | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | if (scalar @columns == 0); | ||||||||||
| 21 | |||||||||||
| 22 | 0 | my @values; | |||||||||
| 23 | 0 | foreach my $c (@columns) { | |||||||||
| 24 | 0 | ▶ | if (exists $hash->{$c}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 0 | push @values, $hash->{$c}; | |||||||||
| 26 | } else { | ||||||||||
| 27 | 0 | $self->_finish_and_croak("query ".$self->{query}." does not return any value named $c"); | |||||||||
| 28 | } | ||||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 0 | return @values; | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | # no more rows to fetch. | ||||||||||
| 35 | # TODO: handle specially if it was an error? | ||||||||||
| 36 | 0 | $self->{sth}->finish(); | |||||||||
| 37 | 0 | $self->{sth} = undef; | |||||||||
| 38 | 0 | return undef; | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 1 | 1; | |||||||||
| 42 | |||||||||||
| 43 | __END__ | ||||||||||