line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Teng::Plugin::SearchJoined; |
2
|
1
|
|
|
1
|
|
1078
|
use 5.008001; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
39
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
1
|
|
15
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
53
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.05"; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
569
|
use Teng::Plugin::SearchJoined::Iterator; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
27
|
|
9
|
1
|
|
|
1
|
|
3826
|
use SQL::Maker; |
|
1
|
|
|
|
|
110297
|
|
|
1
|
|
|
|
|
301
|
|
10
|
|
|
|
|
|
|
SQL::Maker->load_plugin('JoinSelect'); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT = qw/search_joined/; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub search_joined { |
15
|
0
|
|
|
0
|
1
|
|
my ($self, $base_table, $join_conditions, $where, $opt) = @_; |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
my @table_names = ($base_table); |
18
|
0
|
|
|
|
|
|
my $i = 0; |
19
|
0
|
|
|
|
|
|
while (my $table = $join_conditions->[$i]) { |
20
|
0
|
|
|
|
|
|
push @table_names, $table; |
21
|
0
|
|
|
|
|
|
$i += 2; |
22
|
|
|
|
|
|
|
} |
23
|
0
|
|
|
|
|
|
my @tables = map { $self->{schema}->get_table($_) } @table_names; |
|
0
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
my $name_sep = $self->{sql_builder}{name_sep}; |
26
|
0
|
|
|
|
|
|
my @fields; |
27
|
0
|
|
|
|
|
|
for my $table (@tables) { |
28
|
0
|
|
|
|
|
|
my $table_name = $table->name; |
29
|
0
|
|
|
|
|
|
my @columns = map { "$table_name$name_sep$_" } @{ $table->columns }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
push @fields, @columns; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my ($sql, @binds) = $self->{sql_builder}->join_select($base_table, $join_conditions, \@fields, $where, $opt); |
34
|
0
|
|
|
|
|
|
my $sth = $self->execute($sql, \@binds); |
35
|
0
|
|
|
|
|
|
my $itr = Teng::Plugin::SearchJoined::Iterator->new( |
36
|
|
|
|
|
|
|
teng => $self, |
37
|
|
|
|
|
|
|
sth => $sth, |
38
|
|
|
|
|
|
|
sql => $sql, |
39
|
|
|
|
|
|
|
table_names => \@table_names, |
40
|
|
|
|
|
|
|
suppress_object_creation => $self->{suppress_row_objects}, |
41
|
|
|
|
|
|
|
fields => \@fields, |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
$itr; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
__END__ |