| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package ActiveRecord::Simple::Connect; |
|
2
|
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
69
|
use strict; |
|
|
11
|
|
|
|
|
21
|
|
|
|
11
|
|
|
|
|
286
|
|
|
4
|
11
|
|
|
11
|
|
61
|
use warnings; |
|
|
11
|
|
|
|
|
19
|
|
|
|
11
|
|
|
|
|
252
|
|
|
5
|
11
|
|
|
11
|
|
191
|
use 5.010; |
|
|
11
|
|
|
|
|
41
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
11
|
|
|
11
|
|
8023
|
use DBI; |
|
|
11
|
|
|
|
|
98369
|
|
|
|
11
|
|
|
|
|
1697
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $self; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
|
13
|
7
|
|
|
7
|
0
|
42
|
my ($class, $dsn, $username, $password, $params) = @_; |
|
14
|
|
|
|
|
|
|
|
|
15
|
7
|
50
|
|
|
|
32
|
if (!$self) { |
|
16
|
7
|
|
|
|
|
25
|
$self = { dbh => undef }; |
|
17
|
7
|
100
|
|
|
|
29
|
if ($dsn) { |
|
18
|
4
|
|
|
|
|
12
|
$self->{dsn} = $dsn; |
|
19
|
4
|
50
|
|
|
|
16
|
$self->{username} = $username if $username; |
|
20
|
4
|
50
|
|
|
|
14
|
$self->{password} = $password if $password; |
|
21
|
4
|
50
|
|
|
|
15
|
$self->{connection_parameters} = $params if $params; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
7
|
|
|
|
|
16
|
bless $self, $class; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
#$self->db_connect; |
|
27
|
|
|
|
|
|
|
|
|
28
|
7
|
|
|
|
|
24
|
return $self; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub db_connect { |
|
32
|
4
|
|
|
4
|
0
|
10
|
my ($self) = @_; |
|
33
|
|
|
|
|
|
|
|
|
34
|
11
|
|
|
11
|
|
2298
|
use Data::Dumper; |
|
|
11
|
|
|
|
|
23738
|
|
|
|
11
|
|
|
|
|
3415
|
|
|
35
|
4
|
|
|
|
|
161
|
say '-------'; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$self->{dbh} = DBI->connect( |
|
38
|
|
|
|
|
|
|
$self->{dsn}, |
|
39
|
|
|
|
|
|
|
$self->{username}, |
|
40
|
|
|
|
|
|
|
$self->{password}, |
|
41
|
|
|
|
|
|
|
#$self->{connection_parameters}, |
|
42
|
|
|
|
|
|
|
{ |
|
43
|
|
|
|
|
|
|
HandleError => sub { |
|
44
|
0
|
|
|
0
|
|
0
|
my ($a, $b, $c) = @_; |
|
45
|
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
0
|
say 'Simple.Connect.db_connect.HandleError.a = ' . Dumper $a; |
|
47
|
|
|
|
|
|
|
}, |
|
48
|
|
|
|
|
|
|
} |
|
49
|
4
|
50
|
|
|
|
100
|
) or die DBI->errstr; |
|
50
|
|
|
|
|
|
|
|
|
51
|
4
|
|
|
|
|
5660
|
return $self; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub username { |
|
55
|
0
|
|
|
0
|
0
|
0
|
my ($self, $username) = @_; |
|
56
|
|
|
|
|
|
|
|
|
57
|
0
|
0
|
|
|
|
0
|
$self->{username} = $username if $username; |
|
58
|
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
0
|
return $self->{username}; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub password { |
|
63
|
0
|
|
|
0
|
0
|
0
|
my ($self, $password) = @_; |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
0
|
$self->{password} = $password if $password; |
|
66
|
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
0
|
return $self->{password}; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub dsn { |
|
71
|
0
|
|
|
0
|
0
|
0
|
my ($self, $dsn) = @_; |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
0
|
$self->{dsn} = $dsn; |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
0
|
return $self->{dsn}; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub connection_parameters { |
|
79
|
0
|
|
|
0
|
0
|
0
|
my ($self, $connection_parameters) = @_; |
|
80
|
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
0
|
$self->{connection_parameters} = $connection_parameters; |
|
82
|
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
0
|
return $self->{connection_parameters}; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub dbh { |
|
87
|
320
|
|
|
320
|
0
|
500
|
my ($self, $dbh) = @_; |
|
88
|
|
|
|
|
|
|
|
|
89
|
320
|
100
|
|
|
|
588
|
$self->{dbh} = $dbh if $dbh; |
|
90
|
320
|
50
|
33
|
|
|
1350
|
$self->db_connect unless $self->{dbh} && $self->{dbh}->ping; |
|
91
|
|
|
|
|
|
|
|
|
92
|
320
|
|
|
|
|
5298
|
return $self->{dbh}; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |