blib/lib/Teng/Plugin/SearchBySQLAbstractMore/Pager/MySQLFoundRows.pm

filter: Statementstmt 64.1% 25 / 39 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 50.0% 1 / 2 totaltotal 63.4% 33 / 52 CC 2 SCAR 7.4
CC
2
Cov
61%
search_by_sql_abstract_more_with_pager
6.0
init
2.0
BEGIN
1.0
CRAP 2.1
« blib/lib/Teng/Plugin/SearchBySQLAbstractMore/Pager/Count.pm ↑ Summary blib/lib/Teng/Plugin/SearchBySQLAbstractMore/Pager.pm »
1 package Teng::Plugin::SearchBySQLAbstractMore::Pager::MySQLFoundRows;
2  
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 utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Teng::Iterator;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Data::Page;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Teng::Plugin::SearchBySQLAbstractMore ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 our @EXPORT = qw/search_by_sql_abstract_more_with_pager/;
12  
13 sub init {
14 0 ▶ $_[1]->Teng::Plugin::SearchBySQLAbstractMore::_init();
Subroutine init: not called CC=1 SCAR=6.9
Pod undocumented
15 }
16  
17 # work around
18 1 push @EXPORT, qw/sql_abstract_more_instance/;
19 1 *sql_abstract_more_instance = \&Teng::Plugin::SearchBySQLAbstractMore::sql_abstract_more_instance;
20  
21 sub search_by_sql_abstract_more_with_pager {
22 0 ▶ my ($self, $table_name, $where, $_opt) = @_;
Subroutine search_by_sql_abstract_more_with_pager: not called CC=2 SCAR=17.9
Pod documented
23 0 ($table_name, my($args, $rows, $page)) = Teng::Plugin::SearchBySQLAbstractMore::_arrange_args($table_name, $where, $_opt);
24  
25 0 ▶ my $table = $self->schema->get_table($table_name) or Carp::croak("No such table $table_name");
Branch: 1 branch
BranchTrueFalseTotal
my $table = $self->schema->get_table($table_name) or Carp::croak("No such table $table_name") 0 0 0
26  
27 0 my ($sql, @binds) = $self->sql_abstract_more_instance->select(%$args);
28 0 $sql =~s{^\s*SELECT }{SELECT SQL_CALC_FOUND_ROWS }i;
29 0 my $sth = $self->execute($sql, \@binds);
30 0 my $total_entries = $self->dbh->selectrow_array(q{SELECT FOUND_ROWS()});
31 0 my $itr = Teng::Iterator->new(
32 teng => $self,
33 sth => $sth,
34 sql => $sql,
35 row_class => $self->schema->get_row_class($table_name),
36 table_name => $table_name,
37 suppress_object_creation => $self->suppress_row_objects,
38 );
39  
40 0 my $pager = Data::Page->new();
41 0 $pager->entries_per_page($rows);
42 0 $pager->current_page($page);
43 0 $pager->total_entries($total_entries);
44 0 return ([$itr->all], $pager);
45 }
46  
47 =pod
48  
49 =head1 NAME
50  
51 Teng::Plugin::SearchBySQLAbstractMore::Pager::MySQLFoundRows - pager plugin using SQL::AbstractMore. count total entry by MySQL FOUND_ROWS()
52  
53 =head1 SYNOPSIS
54  
55 see Teng::Plugin::SearchBySQLAbstractMore
56  
57 =head1 METHODS
58  
59 =head2 search_by_sql_abstract_more_with_pager
60  
61 C<search_by_sql_abstract_more> with paging feature.
62 additional parameter can be taken, C<page> and C<rows>.
63  
64 =head1 AUTHOR
65  
66 Ktat, C<< <ktat at cpan.org> >>
67  
68 =head1 BUGS
69  
70 Please report any bugs or feature requests to C<bug-teng-plugin-searchbysqlabstractmore at rt.cpan.org>, or through
71 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Teng-Plugin-SearchBySQLAbstractMore>. I will be notified, and then you'll
72 automatically be notified of progress on your bug as I make changes.
73  
74 =head1 SUPPORT
75  
76 You can find documentation for this module with the perldoc command.
77  
78 perldoc Teng::Plugin::SearchBySQLAbstractMore
79  
80 You can also look for information at:
81  
82 =over 4
83  
84 =item * RT: CPAN's request tracker
85  
86 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Teng-Plugin-SearchBySQLAbstractMore>
87  
88 =item * AnnoCPAN: Annotated CPAN documentation
89  
90 L<http://annocpan.org/dist/Teng-Plugin-SearchBySQLAbstractMore>
91  
92 =item * CPAN Ratings
93  
94 L<http://cpanratings.perl.org/d/Teng-Plugin-SearchBySQLAbstractMore>
95  
96 =item * Search CPAN
97  
98 L<http://search.cpan.org/dist/Teng-Plugin-SearchBySQLAbstractMore/>
99  
100 =back
101  
102  
103 =head1 ACKNOWLEDGEMENTS
104  
105  
106 =head1 LICENSE AND COPYRIGHT
107  
108 Copyright 2012 Ktat.
109  
110 This program is free software; you can redistribute it and/or modify it
111 under the terms of either: the GNU General Public License as published
112 by the Free Software Foundation; or the Artistic License.
113  
114 See http://dev.perl.org/licenses/ for more information.
115  
116  
117 =cut
118  
119 1 1; # End of Teng::Plugin::SearchBySQLAbstractMore::Pager::MySQLFoundRows
« blib/lib/Teng/Plugin/SearchBySQLAbstractMore/Pager/Count.pm ↑ Summary blib/lib/Teng/Plugin/SearchBySQLAbstractMore/Pager.pm »