line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::ReluctantORM::DBH; |
2
|
42
|
|
|
42
|
|
365227
|
use strict; |
|
42
|
|
|
|
|
105
|
|
|
42
|
|
|
|
|
1514
|
|
3
|
42
|
|
|
42
|
|
222
|
use warnings; |
|
42
|
|
|
|
|
80
|
|
|
42
|
|
|
|
|
1428
|
|
4
|
|
|
|
|
|
|
|
5
|
42
|
|
|
42
|
|
29195
|
use Class::ReluctantORM::DBH::WrapDBI; |
|
42
|
|
|
|
|
145
|
|
|
42
|
|
|
|
|
524
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Class::ReluctantORM::DBH - Database handle base class |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
This class is used to define an interface for low-level calls to the database handle. In most circumstances, it is a thin wrapper around a DBI database handle. You can use this as a shim to intercept connection calls, manage server timeouts, etc. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Most users will simply use Class::ReluctantORM::DBH::WrapDBI, which directly wraps a DBI database handle. In fact, if you simply pass a DBI database handle to build_class, WrapDBI will be loaded and used for you. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
42
|
|
|
42
|
|
35095
|
use Class::ReluctantORM::Exception; |
|
42
|
|
|
|
|
169
|
|
|
42
|
|
|
|
|
23387
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 ABSTRACT INTERFACE |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head2 $dbh = YourDBHClass->new(); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Creates a new, connected database handle. This can be a singleton or pooled connection. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
0
|
1
|
|
sub new { Class::ReluctantORM::Exception::Call::PureVirtual->croak(); } |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head2 $value = $dbh->get_info($info_id); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
A direct passthru to DBI::dbh->get_info. Used to query things like database vendor, version, quote characters, etc. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
0
|
1
|
|
sub get_info { Class::ReluctantORM::Exception::Call::PureVirtual->croak(); } |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 $dbh->set_handle_error($coderef); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Installs the coderef such that it will be called when a database error occurs. Used to attach a hook to re-throw the error as a Class::ReluctantORM::Exception::SQL::ExecutionError. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
0
|
1
|
|
sub set_handle_error { Class::ReluctantORM::Exception::Call::PureVirtual->croak(); } |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 $sth = $sbh->prepare($sql_string); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Turn the given SQL string into a DBI statement handle. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
0
|
1
|
|
sub prepare { Class::ReluctantORM::Exception::Call::PureVirtual->croak(); } |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 $meta_sth = $dbh->column_info($catalog, $schema, $table, $column); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Returns a statement handle with data about the columns in the database. See DBI::column_info. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
0
|
1
|
|
sub column_info { Class::ReluctantORM::Exception::Call::PureVirtual->croak(); } |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 $dbi_dbh = $cro_dbh->dbi_dbh(); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
If the CRO DBH is based on DBI, this returns the DBI database handle. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
0
|
1
|
|
sub dbi_dbh { return $_[0]->{_dbh}; } |
73
|
0
|
|
|
0
|
|
|
sub __post_connect_hook { } |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub _boost_to_cro_dbh { |
77
|
0
|
|
|
0
|
|
|
my $crod = shift; |
78
|
0
|
|
|
|
|
|
my $dbh = shift; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# It may already support CROD |
81
|
0
|
|
|
|
|
|
eval { |
82
|
0
|
|
|
|
|
|
$crod->_quack_check($dbh); |
83
|
|
|
|
|
|
|
}; |
84
|
0
|
0
|
|
|
|
|
unless ($@) { |
85
|
|
|
|
|
|
|
# Looks OK |
86
|
0
|
|
|
|
|
|
return $dbh; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
return Class::ReluctantORM::DBH::WrapDBI->new($dbh); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub _quack_check { |
96
|
0
|
|
|
0
|
|
|
my $crod = shift; |
97
|
0
|
|
|
|
|
|
my $db_class = shift; |
98
|
0
|
|
|
|
|
|
foreach my $method (qw(new prepare execute set_handle_error get_info column_info dbi_dbh)) { |
99
|
0
|
0
|
|
|
|
|
unless ($db_class->can($method)) { OmniTI::Exception::Param->croak(message => "db_class must support $method method.", param => 'db_class', value => $db_class); } |
|
0
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 AUTHOR |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Clinton Wolfe clwolfe@cpan.org March 2010 |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
1; |