dbMan/Extension/TotalCount.pm untested

filter: Statementstmt 0.0% 0 / 23 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 60 CC 5 SCAR 26.9
CC
5
Cov
0%
handle_action
30.0
IDENTIFICATION
2.0
preference
2.0
CRAP 14.7
1 package DBIx::dbMan::Extension::TotalCount;
2  
3 use strict;
4 use base 'DBIx::dbMan::Extension';
5  
6 our $VERSION = '0.03';
7  
8 1;
9  
10 sub IDENTIFICATION { return "000001-000073-000003"; }
11  
12 sub preference { return -30; }
13  
14 sub known_actions { return [ qw/OUTPUT/ ]; }
15  
16 sub init {
17 my $obj = shift;
18 $obj->{-mempool}->set('total_count',1);
19 }
20  
21 sub handle_action {
22 my ($obj,%action) = @_;
23  
24 $action{processed} = 1;
25 if ($action{action} eq 'OUTPUT' and $action{type} eq 'select' and $action{sql} and $obj->{-mempool}->get('total_count') and defined $action{result}) {
26 my $num = scalar @{$action{result}};
27 my $cols = scalar @{$action{fieldnames}};
28 $action{output} .= ($num==0?"No":"Total $num")." line".($num==1?"":"s")." of output in $cols column".($cols==1?"":"s").".\n";
29 }
30  
31 return %action;
32 }