| 1 | # -*-perl-*- | ||||||||||||||||||||||||||||||
| 2 | # Creation date: 2004-04-21 10:45:30 | ||||||||||||||||||||||||||||||
| 3 | # Authors: Don | ||||||||||||||||||||||||||||||
| 4 | # Change log: | ||||||||||||||||||||||||||||||
| 5 | # $Revision: 1963 $ | ||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||
| 7 | # Copyright (c) 2004-2012 Don Owens | ||||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||||
| 9 | # All rights reserved. This program is free software; you can | ||||||||||||||||||||||||||||||
| 10 | # redistribute it and/or modify it under the same terms as Perl | ||||||||||||||||||||||||||||||
| 11 | # itself. | ||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||
| 15 | { package DBIx::Wrapper::SelectExecLoop; | ||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||
| 17 | 2 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 18 | 2 | $VERSION = do { my @r=(q$Revision: 1963 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r }; | |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | use base 'DBIx::Wrapper::Statement'; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 23 | 0 | my ($proto, $parent, $query, $multi) = @_; | |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||
| 25 | 0 | my $r = DBIx::Wrapper::Request->new($parent); | |||||||||||||||||||||||||||||
| 26 | 0 | $r->setQuery($query); | |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||
| 28 | 0 | $parent->_runPrePrepareHook($r); | |||||||||||||||||||||||||||||
| 29 | 0 | $query = $r->getQuery; | |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||
| 31 | 0 | my $sth = $parent->_getDatabaseHandle()->prepare($query); | |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||
| 33 | 0 | $r->setStatementHandle($sth); | |||||||||||||||||||||||||||||
| 34 | 0 | $parent->_runPostPrepareHook($r); | |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||
| 36 | 0 | $r->setStatementHandle($sth); | |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | unless ($sth) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 39 | 0 | $parent->_printDbiError("\nQuery was '$query'\n"); | |||||||||||||||||||||||||||||
| 40 | 0 | return $parent->setErr(0, $DBI::errstr); | |||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | my $self = | ||||||||||||||||||||||||||||
|
Condition0%0/5
$multi || ''
ref $proto || $proto
MC/DC0%0/1
$multi || ''
$multi
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table0%0/2
A
A= $multi
Truth table0%0/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||||
| 44 | bless { _query => $query, _multi => $multi || '' }, ref($proto) || $proto; | ||||||||||||||||||||||||||||||
| 45 | 0 | $self->_setSth($sth); | |||||||||||||||||||||||||||||
| 46 | 0 | $self->_setParent($parent); | |||||||||||||||||||||||||||||
| 47 | 0 | $self->_setQuery($query); | |||||||||||||||||||||||||||||
| 48 | 0 | $self->_setRequestObj($r); | |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||
| 50 | 0 | return $self; | |||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | sub next { | ||||||||||||||||||||||||||||
|
Subroutine
next: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 54 | 0 | my ($self, $exec_args) = @_; | |||||||||||||||||||||||||||||
| 55 | 0 | my $query = $self->_getQuery; | |||||||||||||||||||||||||||||
| 56 | 0 | my $sth = $self->_getSth; | |||||||||||||||||||||||||||||
| 57 | 0 | my $r = $self->_getRequestObj; | |||||||||||||||||||||||||||||
| 58 | 0 | $r->setExecArgs($exec_args); | |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | if ($$self{_multi}) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 61 | 0 | $self->_getParent()->_runPreExecHook($r); | |||||||||||||||||||||||||||||
| 62 | 0 | $exec_args = $r->getExecArgs; | |||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||
| 64 | 0 | my $rv = $sth->execute(@$exec_args); | |||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||
| 66 | 0 | $r->setExecReturnValue($rv); | |||||||||||||||||||||||||||||
| 67 | 0 | $self->_getParent()->_runPostExecHook($r); | |||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||
| 69 | 0 | $self->_getParent()->_runPreFetchHook($r); | |||||||||||||||||||||||||||||
| 70 | 0 | $sth = $r->getStatementHandle; | |||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | if ($rv) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 73 | 0 | my $rows = []; | |||||||||||||||||||||||||||||
| 74 | 0 | my $row = $sth->fetchrow_hashref($self->_getParent()->getNameArg); | |||||||||||||||||||||||||||||
| 75 | 0 | ▶ | while ($row) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 76 | 0 | $r->setReturnVal($row); | |||||||||||||||||||||||||||||
| 77 | 0 | $self->_getParent()->_runPostFetchHook($r); | |||||||||||||||||||||||||||||
| 78 | 0 | $row = $r->getReturnVal; | |||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | push @$rows, $row if $row; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||
| 82 | 0 | $self->_getParent()->_runPreFetchHook($r); | |||||||||||||||||||||||||||||
| 83 | 0 | $sth = $r->getStatementHandle; | |||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||
| 85 | 0 | $row = $sth->fetchrow_hashref($self->_getParent()->getNameArg); | |||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||
| 87 | 0 | return $rows; | |||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||
| 90 | } else { | ||||||||||||||||||||||||||||||
| 91 | 0 | $self->_getParent()->_runPreExecHook($r); | |||||||||||||||||||||||||||||
| 92 | 0 | $exec_args = $r->getExecArgs; | |||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||
| 94 | 0 | my $rv = $sth->execute(@$exec_args); | |||||||||||||||||||||||||||||
| 95 | 0 | $r->setExecReturnValue($rv); | |||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||
| 97 | 0 | $self->_getParent()->_runPostExecHook($r); | |||||||||||||||||||||||||||||
| 98 | 0 | ▶ | if ($rv) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 99 | 0 | $self->_getParent()->_runPreFetchHook($r); | |||||||||||||||||||||||||||||
| 100 | 0 | $sth = $r->getStatementHandle; | |||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||
| 102 | 0 | my $result = $sth->fetchrow_hashref($self->_getParent()->getNameArg); | |||||||||||||||||||||||||||||
| 103 | 0 | $r->setReturnVal($result); | |||||||||||||||||||||||||||||
| 104 | 0 | $self->_getParent()->_runPostFetchHook($r); | |||||||||||||||||||||||||||||
| 105 | 0 | $result = $r->getReturnVal; | |||||||||||||||||||||||||||||
| 106 | 0 | return $result; | |||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||
| 109 | 0 | return undef; | |||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||
| 113 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||
| 114 | 0 | my $sth = $self->_getSth; | |||||||||||||||||||||||||||||
| 115 | 0 | ▶ | $sth->finish if $sth; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||
| 120 | 2 | 1; | |||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||