line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ActiveRecord::Simple::Connect; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
59
|
use strict; |
|
11
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
260
|
|
4
|
11
|
|
|
11
|
|
50
|
use warnings; |
|
11
|
|
|
|
|
29
|
|
|
11
|
|
|
|
|
220
|
|
5
|
11
|
|
|
11
|
|
171
|
use 5.010; |
|
11
|
|
|
|
|
38
|
|
6
|
|
|
|
|
|
|
|
7
|
11
|
|
|
11
|
|
7478
|
use DBI; |
|
11
|
|
|
|
|
95025
|
|
|
11
|
|
|
|
|
1529
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $self; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
7
|
|
|
7
|
0
|
24
|
my ($class, $dsn, $username, $password, $params) = @_; |
14
|
|
|
|
|
|
|
|
15
|
7
|
50
|
|
|
|
22
|
if (!$self) { |
16
|
7
|
|
|
|
|
21
|
$self = { dbh => undef }; |
17
|
7
|
100
|
|
|
|
24
|
if ($dsn) { |
18
|
4
|
|
|
|
|
9
|
$self->{dsn} = $dsn; |
19
|
4
|
50
|
|
|
|
13
|
$self->{username} = $username if $username; |
20
|
4
|
50
|
|
|
|
10
|
$self->{password} = $password if $password; |
21
|
4
|
50
|
|
|
|
13
|
$self->{connection_parameters} = $params if $params; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
7
|
|
|
|
|
16
|
bless $self, $class; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
#$self->db_connect; |
27
|
|
|
|
|
|
|
|
28
|
7
|
|
|
|
|
19
|
return $self; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub db_connect { |
32
|
4
|
|
|
4
|
0
|
11
|
my ($self) = @_; |
33
|
|
|
|
|
|
|
|
34
|
11
|
|
|
11
|
|
2278
|
use Data::Dumper; |
|
11
|
|
|
|
|
25327
|
|
|
11
|
|
|
|
|
3479
|
|
35
|
4
|
|
|
|
|
166
|
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
|
|
|
|
84
|
) or die DBI->errstr; |
50
|
|
|
|
|
|
|
|
51
|
4
|
|
|
|
|
5353
|
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
|
455
|
my ($self, $dbh) = @_; |
88
|
|
|
|
|
|
|
|
89
|
320
|
100
|
|
|
|
489
|
$self->{dbh} = $dbh if $dbh; |
90
|
320
|
50
|
33
|
|
|
1199
|
$self->db_connect unless $self->{dbh} && $self->{dbh}->ping; |
91
|
|
|
|
|
|
|
|
92
|
320
|
|
|
|
|
4452
|
return $self->{dbh}; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |