line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Teng::Plugin::Pager::DataPageset; |
2
|
1
|
|
|
1
|
|
818
|
use 5.008005; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
59
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
5
|
1
|
|
|
1
|
|
13
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
6
|
1
|
|
|
1
|
|
874
|
use utf8; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
6
|
|
7
|
1
|
|
|
1
|
|
750
|
use Data::Pageset; |
|
1
|
|
|
|
|
88931
|
|
|
1
|
|
|
|
|
116
|
|
8
|
1
|
|
|
1
|
|
1462
|
use Teng::Iterator; |
|
1
|
|
|
|
|
3621
|
|
|
1
|
|
|
|
|
31
|
|
9
|
1
|
|
|
1
|
|
7
|
use Carp (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
576
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT = qw/search_with_data_pageset/; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub search_with_data_pageset { |
16
|
0
|
|
|
0
|
1
|
|
my ($self, $table_name, $where, $opt) = @_; |
17
|
|
|
|
|
|
|
|
18
|
0
|
0
|
|
|
|
|
my $table = $self->schema->get_table($table_name) or Carp::croak("'$table_name' is unknown table"); |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
0
|
|
|
|
my $page = $opt->{page} || 1; |
21
|
0
|
|
0
|
|
|
|
my $rows = $opt->{rows} || 1; |
22
|
0
|
|
0
|
|
|
|
my $mode = $opt->{mode} || 'fixed'; |
23
|
0
|
|
0
|
|
|
|
my $pages_per_set = $opt->{pages_per_set} || 5; |
24
|
0
|
0
|
|
|
|
|
my $total_entries = $opt->{total_entries} or Carp::croak("please input 'total_entries' option"); |
25
|
|
|
|
|
|
|
|
26
|
0
|
0
|
0
|
|
|
|
my $columns = $opt->{'+columns'} ? [@{$table->{columns}}, @{$opt->{'+columns'}}] |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
: ($opt->{columns} || $table->{columns}) |
28
|
|
|
|
|
|
|
; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my ($sql, @binds) = $self->sql_builder->select( |
31
|
|
|
|
|
|
|
$table_name, |
32
|
|
|
|
|
|
|
$columns, |
33
|
|
|
|
|
|
|
$where, +{ |
34
|
|
|
|
|
|
|
%$opt, |
35
|
|
|
|
|
|
|
limit => $rows, |
36
|
|
|
|
|
|
|
offset => $rows*($page-1), |
37
|
|
|
|
|
|
|
}, |
38
|
|
|
|
|
|
|
); |
39
|
0
|
0
|
|
|
|
|
my $sth = $self->dbh->prepare($sql) or Carp::croak $self->dbh->errstr; |
40
|
0
|
0
|
|
|
|
|
$sth->execute(@binds) or Carp::croak $self->dbh->errstr; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my $itr = Teng::Iterator->new( |
43
|
|
|
|
|
|
|
teng => $self, |
44
|
|
|
|
|
|
|
sth => $sth, |
45
|
|
|
|
|
|
|
sql => $sql, |
46
|
|
|
|
|
|
|
row_class => $self->schema->get_row_class($table_name), |
47
|
|
|
|
|
|
|
table => $table, |
48
|
|
|
|
|
|
|
table_name => $table_name, |
49
|
|
|
|
|
|
|
suppress_object_creation => $self->suppress_row_objects, |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my $pager = Data::Pageset->new({ |
53
|
|
|
|
|
|
|
'total_entries' => $total_entries, |
54
|
|
|
|
|
|
|
'entries_per_page' => $rows, |
55
|
|
|
|
|
|
|
'current_page' => $page, |
56
|
|
|
|
|
|
|
'pages_per_set' => $pages_per_set, |
57
|
|
|
|
|
|
|
'mode' => $mode, |
58
|
|
|
|
|
|
|
}); |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
return ([$itr->all], $pager); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |