line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Creation date: 2005-10-16 20:42:19 |
2
|
|
|
|
|
|
|
# Authors: don |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# Copyright (c) 2005-2012 Don Owens . All rights reserved. |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it |
7
|
|
|
|
|
|
|
# under the same terms as Perl itself. See perlartistic. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be |
10
|
|
|
|
|
|
|
# useful, but WITHOUT ANY WARRANTY; without even the implied |
11
|
|
|
|
|
|
|
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
12
|
|
|
|
|
|
|
# PURPOSE. |
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
67
|
|
15
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
93
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
package DBIx::Wrapper::DBIDelegator; |
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
2
|
|
10
|
use vars qw($VERSION); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
175
|
|
20
|
|
|
|
|
|
|
$VERSION = do { my @r=(q$Revision: 1963 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r }; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# use Scalar::Util qw(refaddr); |
23
|
2
|
|
|
2
|
|
13
|
use Carp qw(cluck); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
2107
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my %i_data; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub refaddr($) { |
28
|
0
|
|
|
0
|
0
|
|
my $obj = shift; |
29
|
0
|
0
|
|
|
|
|
my $pkg = ref($obj) or return undef; |
30
|
0
|
|
|
|
|
|
bless $obj, 'DBIx::Wrapper::Fake'; |
31
|
0
|
|
|
|
|
|
my $i = int($obj); |
32
|
0
|
|
|
|
|
|
bless $obj, $pkg; |
33
|
0
|
|
|
|
|
|
return $i; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _new { |
38
|
0
|
|
|
0
|
|
|
my $proto = shift; |
39
|
0
|
|
0
|
|
|
|
my $self = bless {}, ref($proto) || $proto; |
40
|
0
|
|
|
|
|
|
$i_data{ refaddr($self) } = {}; |
41
|
0
|
|
|
|
|
|
return $self; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub TIEHASH { |
45
|
0
|
|
|
0
|
|
|
my $proto = shift; |
46
|
0
|
|
|
|
|
|
my $dbix_dbh = shift; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my $self = $proto->_new; |
49
|
0
|
|
|
|
|
|
$i_data{ refaddr($self) }{_dbix_dbh} = $dbix_dbh; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
return $self; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub _get_dbi { |
55
|
0
|
|
|
0
|
|
|
my $self = shift; |
56
|
0
|
|
|
|
|
|
return $i_data{ refaddr($self) }{_dbix_dbh}->get_dbi; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub FETCH { |
60
|
0
|
|
|
0
|
|
|
my $self = shift; |
61
|
0
|
|
|
|
|
|
my $key = shift; |
62
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
if ($key =~ /\A_(?:dbh|username|auth|attr|data_source_str|dbd_driver|db_style|debug)\Z/) { |
64
|
0
|
|
|
|
|
|
my ($package, $filename, $line, $subroutine, $hasargs, |
65
|
|
|
|
|
|
|
$wantarray, $evaltext, $is_require, $hints, $bitmask); |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my $frame = 1; |
68
|
0
|
|
|
|
|
|
my $this_pkg = __PACKAGE__; |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
($package, $filename, $line, $subroutine, $hasargs, |
71
|
|
|
|
|
|
|
$wantarray, $evaltext, $is_require, $hints, $bitmask) = caller($frame); |
72
|
0
|
|
0
|
|
|
|
while (defined($package) and $package eq $this_pkg) { |
73
|
0
|
|
|
|
|
|
$frame++; |
74
|
0
|
|
|
|
|
|
($package, $filename, $line, $subroutine, $hasargs, |
75
|
|
|
|
|
|
|
$wantarray, $evaltext, $is_require, $hints, $bitmask) = caller($frame); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# if we get more than 10 something must be wrong |
78
|
0
|
0
|
|
|
|
|
last if $frame >= 10; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
local($Carp::CarpLevel) = $frame; |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
cluck "Accessing DBIx::Wrapper's internal data directly. Don't do that."; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
return $self->_get_dbi()->{$key}; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub STORE { |
90
|
0
|
|
|
0
|
|
|
my $self = shift; |
91
|
0
|
|
|
|
|
|
my $key = shift; |
92
|
0
|
|
|
|
|
|
my $value = shift; |
93
|
0
|
|
|
|
|
|
my $dbi = $self->_get_dbi; |
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
$self->_get_dbi()->{$key} = $value; |
96
|
0
|
|
|
|
|
|
return $value; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub DELETE { |
100
|
0
|
|
|
0
|
|
|
my $self = shift; |
101
|
0
|
|
|
|
|
|
my $key = shift; |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
return delete $self->_get_dbi()->{$key}; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub CLEAR { |
107
|
0
|
|
|
0
|
|
|
my $self = shift; |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
%{ $self->_get_dbi() } = (); |
|
0
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub EXISTS { |
113
|
0
|
|
|
0
|
|
|
my $self = shift; |
114
|
0
|
|
|
|
|
|
my $key = shift; |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
return exists $self->_get_dbi()->{$key}; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub FIRSTKEY { |
120
|
0
|
|
|
0
|
|
|
my $self = shift; |
121
|
0
|
|
|
|
|
|
my $dbi = $self->_get_dbi; |
122
|
0
|
|
|
|
|
|
my $cnt = keys %$dbi; # reset each() iterator |
123
|
0
|
|
|
|
|
|
return each %$dbi; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub NEXTKEY { |
127
|
0
|
|
|
0
|
|
|
my $self = shift; |
128
|
0
|
|
|
|
|
|
my $last_key = shift; |
129
|
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
|
return each %{ $self->_get_dbi }; |
|
0
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub SCALAR { |
134
|
0
|
|
|
0
|
|
|
my $self = shift; |
135
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
return scalar(%{ $self->_get_dbi }); |
|
0
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
0
|
|
|
sub UNTIE { |
140
|
|
|
|
|
|
|
# noop |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub DESTROY { |
144
|
0
|
|
|
0
|
|
|
my $self = shift; |
145
|
|
|
|
|
|
|
|
146
|
0
|
|
|
|
|
|
delete $i_data{ refaddr($self) }; |
147
|
0
|
|
|
|
|
|
return; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
1; |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
# Local Variables: # |
153
|
|
|
|
|
|
|
# mode: perl # |
154
|
|
|
|
|
|
|
# tab-width: 4 # |
155
|
|
|
|
|
|
|
# indent-tabs-mode: nil # |
156
|
|
|
|
|
|
|
# cperl-indent-level: 4 # |
157
|
|
|
|
|
|
|
# perl-indent-level: 4 # |
158
|
|
|
|
|
|
|
# End: # |
159
|
|
|
|
|
|
|
# vim:set ai si et sta ts=4 sw=4 sts=4: |