line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
3
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
101
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
### |
6
|
|
|
|
|
|
|
# DBIx::Encoding |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
package DBIx::Encoding; |
9
|
1
|
|
|
1
|
|
5
|
use base qw(DBI); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
690
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use version; |
12
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
### |
15
|
|
|
|
|
|
|
# DBIx::Encoding::db |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
package DBIx::Encoding::db; |
18
|
|
|
|
|
|
|
use base qw(DBI::db); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub connected { |
21
|
|
|
|
|
|
|
my ($self, $dsn, $user, $credential, $attrs) = @_; |
22
|
|
|
|
|
|
|
$self->{private_dbix_encoding} = { 'encoding' => $attrs->{encoding} || 'utf8' }; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub prepare { |
26
|
|
|
|
|
|
|
my ($self, @args) = @_; |
27
|
|
|
|
|
|
|
my $sth = $self->SUPER::prepare(@args) or return; |
28
|
|
|
|
|
|
|
$sth->{private_dbix_encoding} = $self->{private_dbix_encoding}; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
return $sth; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub do { |
34
|
|
|
|
|
|
|
my ($self, $stmt, $attr, @args) = @_; |
35
|
|
|
|
|
|
|
my $encoding = $self->{private_dbix_encoding}->{encoding}; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
@args = map { Encode::encode($encoding, $_) } @args; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
return $self->SUPER::do($stmt, $attr, @args); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
### |
43
|
|
|
|
|
|
|
# DBIx::Encoding::st |
44
|
|
|
|
|
|
|
# |
45
|
|
|
|
|
|
|
package DBIx::Encoding::st; |
46
|
|
|
|
|
|
|
use base qw(DBI::st); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
use Encode; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub bind_param { |
51
|
|
|
|
|
|
|
my ($self, @args) = @_; |
52
|
|
|
|
|
|
|
my $encoding = $self->{private_dbix_encoding}->{encoding}; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
$args[1] = Encode::encode($encoding, $args[1]); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
return $self->SUPER::bind_param(@args); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub execute { |
60
|
|
|
|
|
|
|
my ($self, @args) = @_; |
61
|
|
|
|
|
|
|
my $encoding = $self->{private_dbix_encoding}->{encoding}; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
@args = map { Encode::encode($encoding, $_) } @args; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
return $self->SUPER::execute(@args); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub fetch { |
69
|
|
|
|
|
|
|
my ($self, @args) = @_; |
70
|
|
|
|
|
|
|
my $encoding = $self->{private_dbix_encoding}->{encoding}; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my $row = $self->SUPER::fetch(@args) or return; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
for my $val (@$row) { |
75
|
|
|
|
|
|
|
$val = Encode::decode($encoding, $val); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
return $row; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub fetchrow_array { |
82
|
|
|
|
|
|
|
my $self = shift; |
83
|
|
|
|
|
|
|
my $encoding = $self->{private_dbix_encoding}->{encoding}; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
my @array = $self->SUPER::fetchrow_array or return; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
return map { Encode::decode($encoding, $_) } @array; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub fetchall_arrayref { |
91
|
|
|
|
|
|
|
my ($self, $slice, $max_rows) = @_; |
92
|
|
|
|
|
|
|
my $encoding = $self->{private_dbix_encoding}->{encoding}; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
my $array_ref; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
if ($slice) { |
97
|
|
|
|
|
|
|
$array_ref = $self->SUPER::fetchall_arrayref($slice, $max_rows) or return; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
else { |
100
|
|
|
|
|
|
|
$array_ref = $self->SUPER::fetchall_arrayref or return; |
101
|
|
|
|
|
|
|
for my $array (@{ $array_ref }) { |
102
|
|
|
|
|
|
|
@{ $array } = map { Encode::decode($encoding, $_) } @{ $array }; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
return $array_ref; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
1; |
110
|
|
|
|
|
|
|
__END__ |