line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
############################################################################# |
2
|
|
|
|
|
|
|
## Name: MOD.pm |
3
|
|
|
|
|
|
|
## Purpose: HDB::MOD - Common things for HDB modules. |
4
|
|
|
|
|
|
|
## Author: Graciliano M. P. |
5
|
|
|
|
|
|
|
## Modified by: |
6
|
|
|
|
|
|
|
## Created: 15/01/2003 |
7
|
|
|
|
|
|
|
## RCS-ID: |
8
|
|
|
|
|
|
|
## Copyright: (c) 2002 Graciliano M. P. |
9
|
|
|
|
|
|
|
## Licence: This program is free software; you can redistribute it and/or |
10
|
|
|
|
|
|
|
## modify it under the same terms as Perl itself |
11
|
|
|
|
|
|
|
############################################################################# |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package HDB::MOD ; |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
29793
|
use DBI ; |
|
1
|
|
|
|
|
37861
|
|
|
1
|
|
|
|
|
3069
|
|
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
16
|
use strict qw(vars) ; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
18
|
1
|
|
|
1
|
|
6
|
no warnings ; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
735
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '1.0' ; |
21
|
|
|
|
|
|
|
our @ISA = qw(HDB::CMDS HDB) ; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
############### |
24
|
|
|
|
|
|
|
# VAR ALIASES # |
25
|
|
|
|
|
|
|
############### |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
0
|
0
|
|
sub dbi { $_[0]->{dbh} ;} |
28
|
0
|
|
|
0
|
1
|
|
sub dbh { $_[0]->{dbh} ;} |
29
|
0
|
|
|
0
|
0
|
|
sub sth { $_[0]->{sth} ;} |
30
|
0
|
|
|
0
|
0
|
|
sub sql { $_[0]->{sql} ;} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
############# |
33
|
|
|
|
|
|
|
# CONNECTED # |
34
|
|
|
|
|
|
|
############# |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub connected { |
37
|
0
|
0
|
|
0
|
0
|
|
if ( !$_[0]->dbh ) { return undef ;} |
|
0
|
|
|
|
|
|
|
38
|
0
|
0
|
|
|
|
|
if ( $_[0]->dbh->{Active} ) { return 1 ;} |
|
0
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
return undef ; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
############## |
43
|
|
|
|
|
|
|
# DISCONNECT # |
44
|
|
|
|
|
|
|
############## |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub disconnect { |
47
|
0
|
|
|
0
|
1
|
|
my $this = shift ; |
48
|
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
|
$this->{sth}->finish if $this->{sth} ; |
50
|
0
|
|
|
|
|
|
$this->{sth} = undef ; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
$this->flush_cache ; |
53
|
|
|
|
|
|
|
|
54
|
0
|
0
|
|
|
|
|
if ( $this->{dbh} ) { |
55
|
0
|
0
|
|
|
|
|
$this->{dbh}->commit if !$this->{dbh}->{AutoCommit} ; |
56
|
0
|
0
|
|
|
|
|
$this->MOD_disconnect if !$this->{dbh}->{Kids} ; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
$this->{dbh} = undef ; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
return ; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
################## |
65
|
|
|
|
|
|
|
# MOD_DISCONNECT # |
66
|
|
|
|
|
|
|
################## |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub MOD_disconnect { |
69
|
0
|
|
|
0
|
0
|
|
my $this = shift ; |
70
|
0
|
|
|
|
|
|
$this->{dbh}->disconnect ; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
######## |
74
|
|
|
|
|
|
|
# LINK # |
75
|
|
|
|
|
|
|
######## |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub LINK { |
78
|
0
|
0
|
|
0
|
0
|
|
if ( $_[0]->{HPL}{UNLINK_DISCONNECT} ) { $_[0]->connect ;} |
|
0
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
########## |
82
|
|
|
|
|
|
|
# UNLINK # |
83
|
|
|
|
|
|
|
########## |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub UNLINK { |
86
|
0
|
|
|
0
|
0
|
|
$_[0]->flush_cache ; |
87
|
0
|
0
|
|
|
|
|
if ( $_[0]->{sth} ) { $_[0]->{sth}->finish ; $_[0]->{sth} = undef ;} |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
88
|
0
|
0
|
|
|
|
|
if ( $_[0]->{HPL}{UNLINK_DISCONNECT} ) { $_[0]->disconnect ;} |
|
0
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
###### |
92
|
|
|
|
|
|
|
# DO # |
93
|
|
|
|
|
|
|
###### |
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
0
|
0
|
|
sub do { $_[0]->{dbh}->do(@_[1..$#_]) ;} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
########### |
98
|
|
|
|
|
|
|
# PREPARE # |
99
|
|
|
|
|
|
|
########### |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
0
|
0
|
|
sub prepare { $_[0]->{dbh}->prepare(@_[1..$#_]) ;} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
########### |
104
|
|
|
|
|
|
|
# EXECUTE # |
105
|
|
|
|
|
|
|
########### |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
0
|
0
|
|
sub execute { $_[0]->{sth}->execute(@_[1..$#_]) ;} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
############# |
110
|
|
|
|
|
|
|
# TYPE_TEXT # |
111
|
|
|
|
|
|
|
############# |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
0
|
0
|
|
sub Type_TEXT { return 'TEXT' ;} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
################ |
116
|
|
|
|
|
|
|
# TYPE_INTEGER # |
117
|
|
|
|
|
|
|
################ |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
0
|
0
|
|
sub Type_INTEGER { return 'INTEGER' ;} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
############## |
122
|
|
|
|
|
|
|
# TYPE_FLOAT # |
123
|
|
|
|
|
|
|
############## |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
0
|
0
|
|
sub Type_FLOAT { return 'FLOAT' ;} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
############## |
128
|
|
|
|
|
|
|
# PRIMARYKEY # |
129
|
|
|
|
|
|
|
############## |
130
|
|
|
|
|
|
|
|
131
|
0
|
|
|
0
|
0
|
|
sub PRIMARYKEY { return "PRIMARY KEY" ;} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
################# |
134
|
|
|
|
|
|
|
# AUTOINCREMENT # |
135
|
|
|
|
|
|
|
################# |
136
|
|
|
|
|
|
|
|
137
|
0
|
|
|
0
|
0
|
|
sub AUTOINCREMENT { return "INTEGER NOT NULL AUTO_INCREMENT" ;} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
######### |
140
|
|
|
|
|
|
|
# LIMIT # |
141
|
|
|
|
|
|
|
######### |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub LIMIT { |
144
|
0
|
|
|
0
|
1
|
|
my $this = shift ; |
145
|
0
|
|
|
|
|
|
my ( $sz , $offset ) = @_ ; |
146
|
0
|
0
|
|
|
|
|
my $limit = $offset > 0 ? "$sz,$offset" : $sz ; |
147
|
0
|
|
|
|
|
|
return( "LIMIT $limit" ) ; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
####### |
151
|
|
|
|
|
|
|
# DBD # |
152
|
|
|
|
|
|
|
####### |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
package DBI ; |
155
|
|
|
|
|
|
|
package DBD ; |
156
|
1
|
|
|
1
|
|
8
|
use vars qw(%HDB) ; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
113
|
|
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
####### |
159
|
|
|
|
|
|
|
# END # |
160
|
|
|
|
|
|
|
####### |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
1; |
163
|
|
|
|
|
|
|
|