line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package IMDB::Local::DB; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
10
|
use 5.006; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
2
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
5
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
IMDB::Local::DB - The great new IMDB::Local::DB! |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Version 0.01 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '1.00'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Quick summary of what the module does. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Perhaps a little code snippet. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
use IMDB::Local::DB; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $foo = IMDB::Local::DB->new(); |
28
|
|
|
|
|
|
|
... |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 EXPORT |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
A list of functions that can be exported. You can delete this section |
33
|
|
|
|
|
|
|
if you don't export anything, such as for a purely object-oriented module. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 new |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
1
|
|
|
1
|
|
3
|
use base qw(IMDB::Local::DB::Base); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
362
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
use Class::MethodMaker |
45
|
|
|
|
|
|
|
[ |
46
|
|
|
|
|
|
|
scalar => [{-default => 0}, 'db_AutoCommit'], |
47
|
|
|
|
|
|
|
scalar => [{-default => 'SQLite'}, 'driver'], |
48
|
|
|
|
|
|
|
scalar => [{-default => ''}, 'driverDetail'], |
49
|
|
|
|
|
|
|
scalar => [{-default => 'imdb.db'}, 'database'], |
50
|
|
|
|
|
|
|
scalar => [{-default => ''}, 'user'], |
51
|
|
|
|
|
|
|
scalar => [{-default => ''}, 'passwd'], |
52
|
|
|
|
|
|
|
new => [qw/ -init -hash new /] , |
53
|
|
|
|
|
|
|
]; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 function2 |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub init($) |
60
|
|
|
|
|
|
|
{ |
61
|
|
|
|
|
|
|
my ($self)=@_; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 function2 |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub delete($) |
69
|
|
|
|
|
|
|
{ |
70
|
|
|
|
|
|
|
my ($self)=@_; |
71
|
|
|
|
|
|
|
unlink($self->database()); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 function2 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub connect($) |
79
|
|
|
|
|
|
|
{ |
80
|
|
|
|
|
|
|
my ($self)=@_; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my $initIt=0; |
83
|
|
|
|
|
|
|
if ( ! -f $self->database ) { |
84
|
|
|
|
|
|
|
$initIt=1; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
my $c=$self->SUPER::connect(); |
88
|
|
|
|
|
|
|
if ( $c ) { |
89
|
|
|
|
|
|
|
#$c->dbh->{AutoCommit}=0; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
if ( $c && $initIt==1 ) { |
92
|
|
|
|
|
|
|
$self->schema_init(); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
return($c); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 function2 |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub schema_init($) |
102
|
|
|
|
|
|
|
{ |
103
|
|
|
|
|
|
|
my ($self)=@_; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
for ($self->table_list) { |
106
|
|
|
|
|
|
|
print "dropping table: $_\n"; |
107
|
|
|
|
|
|
|
$self->runSQL("drop table $_"); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
local $/ = undef; |
111
|
|
|
|
|
|
|
my $sql = ; |
112
|
|
|
|
|
|
|
my @statements = split(/;\s*\n/, $sql); |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
foreach my $stmt (@statements) { |
115
|
|
|
|
|
|
|
next if ($stmt =~ /^\s*$/o); |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
if ( !$self->runSQL($stmt) ) { |
118
|
|
|
|
|
|
|
print "Error executing:\n$stmt\n\n"; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
print $self->dbh->errstr()."\n"; |
121
|
|
|
|
|
|
|
return(0); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
$self->insert_db('Versions', undef, (schema_version=>1)); |
125
|
|
|
|
|
|
|
$self->commit(); |
126
|
|
|
|
|
|
|
return(1); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 AUTHOR |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
jerryv, C<< >> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 BUGS |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
137
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
138
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 SUPPORT |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
perldoc IMDB::Local::DB |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
You can also look for information at: |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=over 4 |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
L |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
L |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item * CPAN Ratings |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
L |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=item * Search CPAN |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
L |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=back |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Copyright 2015 jerryv. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
181
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
182
|
|
|
|
|
|
|
copy of the full license at: |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
L |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
187
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
188
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
189
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
192
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
193
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
196
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
199
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
200
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
201
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
202
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
203
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
204
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
205
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
208
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
209
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
210
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
211
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
212
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
213
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
214
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=cut |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
1; # End of IMDB::Local::DB |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
__DATA__ |