line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBD::Sys::Table; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
DBD::Sys::Table - abstract base class of tables used in DBD::Sys |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=cut |
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
16
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
92
|
|
10
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
75
|
|
11
|
3
|
|
|
3
|
|
15
|
use vars qw(@ISA $VERSION); |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
148
|
|
12
|
|
|
|
|
|
|
|
13
|
3
|
|
|
3
|
|
15
|
use Carp qw(croak); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
175
|
|
14
|
3
|
|
|
3
|
|
14
|
use Scalar::Util qw(blessed); |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
661
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
require SQL::Eval; |
17
|
|
|
|
|
|
|
require DBI::DBD::SqlEngine; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
@ISA = qw(DBI::DBD::SqlEngine::Table); |
20
|
|
|
|
|
|
|
$VERSION = 0.100; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 DESCRIPTION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
DBD::Sys::Table provides an abstract base class to wrap the requirements |
25
|
|
|
|
|
|
|
of SQL::Statement and DBD::Sys on a table around the pure data collecting |
26
|
|
|
|
|
|
|
actions. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 METHODS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 get_col_names |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
This method is called during the construction phase of the table. It must be |
33
|
|
|
|
|
|
|
a I method - the called context is the class name of the constructed |
34
|
|
|
|
|
|
|
object. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
0
|
1
|
0
|
sub get_col_names() { croak "Abstract method 'get_col_names' called"; } |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 collect_data |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
This method is called when the table is constructed but before the first row |
43
|
|
|
|
|
|
|
shall be delivered via C. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
0
|
1
|
0
|
sub collect_data() { croak "Abstract method 'collect_data' called"; } |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 get_primary_key |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
This method returns the column name of the primary key column. If not |
52
|
|
|
|
|
|
|
overwritten, the first column name is returned by C. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
0
|
1
|
0
|
sub get_primary_key() { return ( $_[0]->get_col_names() )[0]; } |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 get_table_name |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Returns the name of the table based on it's class name. |
61
|
|
|
|
|
|
|
Override it to return another table name. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub get_table_name |
66
|
|
|
|
|
|
|
{ |
67
|
12
|
|
|
12
|
1
|
25
|
my $self = $_[0]; |
68
|
12
|
|
33
|
|
|
81
|
my $proto = blessed($self) || $self; |
69
|
|
|
|
|
|
|
|
70
|
12
|
|
|
|
|
20
|
my $tblName; |
71
|
12
|
|
|
|
|
80
|
( $tblName = $proto ) =~ s/.*::(\p{Word}+)$/$1/; |
72
|
|
|
|
|
|
|
|
73
|
12
|
|
|
|
|
40
|
return $tblName; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 get_priority |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Returns the default priority of the controlling plugin. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
To speed up subsequent get_priority calls, a simple method returning the |
81
|
|
|
|
|
|
|
value is injected into the class name space. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub get_priority() |
86
|
|
|
|
|
|
|
{ |
87
|
6
|
|
|
6
|
1
|
13
|
my $self = $_[0]; |
88
|
6
|
|
33
|
|
|
36
|
my $proto = blessed($self) || $self; |
89
|
6
|
|
|
|
|
38
|
( my $plugin = $proto ) =~ s/(.*)::\p{Word}+$/$1/; |
90
|
6
|
|
|
|
|
40
|
my $priority = $plugin->get_priority(); |
91
|
|
|
|
|
|
|
|
92
|
6
|
|
|
2
|
1
|
268
|
eval sprintf( 'sub %s::get_priority { return %d; }', $proto, $priority ); |
|
2
|
|
|
2
|
1
|
48
|
|
|
2
|
|
|
0
|
1
|
21
|
|
|
0
|
|
|
0
|
1
|
0
|
|
|
0
|
|
|
|
|
0
|
|
93
|
|
|
|
|
|
|
|
94
|
6
|
|
|
|
|
71
|
return $priority; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 new |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Constructor - called from C when called |
100
|
|
|
|
|
|
|
from C for tables with one implementor class. |
101
|
|
|
|
|
|
|
The C<$attrs> argument contains the owner statement instance in the field |
102
|
|
|
|
|
|
|
C and the owning database handle in the field . |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub new |
107
|
|
|
|
|
|
|
{ |
108
|
6
|
|
|
6
|
1
|
13
|
my ( $className, $attrs ) = @_; |
109
|
6
|
|
|
|
|
27
|
my %table = ( |
110
|
|
|
|
|
|
|
pos => 0, |
111
|
|
|
|
|
|
|
%$attrs, |
112
|
|
|
|
|
|
|
); |
113
|
6
|
50
|
|
|
|
41
|
exists $table{col_names} |
114
|
|
|
|
|
|
|
or $table{col_names} = [ $className->get_col_names() ]; |
115
|
|
|
|
|
|
|
|
116
|
6
|
|
|
|
|
42
|
my $self = $className->SUPER::new( \%table ); |
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
$self->{data} = $self->collect_data(); |
119
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
|
return $self; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 fetch_row |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Called by C to fetch the single rows. This method return the |
126
|
|
|
|
|
|
|
rows contained in the C attribute of the individual instance. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub fetch_row |
131
|
|
|
|
|
|
|
{ |
132
|
0
|
0
|
|
0
|
1
|
|
unless ( blessed( $_[0] ) ) |
133
|
|
|
|
|
|
|
{ |
134
|
0
|
|
|
|
|
|
my @caller = caller(); |
135
|
0
|
|
|
|
|
|
die "Invalid invocation on unblessed '$_[0]' from $caller[0] at $caller[2] in $caller[1]"; |
136
|
|
|
|
|
|
|
} |
137
|
0
|
|
|
|
|
|
$_[0]->{row} = undef; |
138
|
0
|
0
|
|
|
|
|
if ( $_[0]->{pos} < scalar( @{ $_[0]->{data} } ) ) |
|
0
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
{ |
140
|
0
|
|
|
|
|
|
$_[0]->{row} = $_[0]->{data}->[ ( $_[0]->{pos} )++ ]; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
$_[0]->{row}; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub DESTROY |
147
|
|
|
|
|
|
|
{ |
148
|
0
|
|
|
0
|
|
|
my $self = $_[0]; |
149
|
0
|
|
|
|
|
|
delete $self->{owner}; |
150
|
0
|
|
|
|
|
|
delete $self->{database}; |
151
|
0
|
|
|
|
|
|
delete $self->{meta}; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 AUTHOR |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Jens Rehsack Alexander Breibach |
157
|
|
|
|
|
|
|
CPAN ID: REHSACK |
158
|
|
|
|
|
|
|
rehsack@cpan.org alexander.breibach@googlemail.com |
159
|
|
|
|
|
|
|
http://search.cpan.org/~rehsack/ |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 COPYRIGHT |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
This program is free software; you can redistribute |
164
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
The full text of the license can be found in the |
167
|
|
|
|
|
|
|
LICENSE file included with this module. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 SUPPORT |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Free support can be requested via regular CPAN bug-tracking system. There is |
172
|
|
|
|
|
|
|
no guaranteed reaction time or solution time, but it's always tried to give |
173
|
|
|
|
|
|
|
accept or reject a reported ticket within a week. It depends on business load. |
174
|
|
|
|
|
|
|
That doesn't mean that ticket via rt aren't handles as soon as possible, |
175
|
|
|
|
|
|
|
that means that soon depends on how much I have to do. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Business and commercial support should be acquired from the authors via |
178
|
|
|
|
|
|
|
preferred freelancer agencies. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 SEE ALSO |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
perl(1), L, L, L, L, |
183
|
|
|
|
|
|
|
L. |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=cut |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
#################### main pod documentation end ################### |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
1; |