line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PowerTools::Data;
|
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
22926
|
use 5.000002;
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings;
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
31
|
|
6
|
1
|
|
|
1
|
|
2396
|
use DBI;
|
|
1
|
|
|
|
|
18124
|
|
|
1
|
|
|
|
|
57
|
|
7
|
1
|
|
|
1
|
|
419
|
use DBD::mysql;
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Time::Piece;
|
9
|
|
|
|
|
|
|
use Time::Piece::MySQL;
|
10
|
|
|
|
|
|
|
use Time::HiRes qw(time);
|
11
|
|
|
|
|
|
|
use Config::IniHash;
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
require Exporter;
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @ISA = qw(Exporter);
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export
|
18
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead.
|
19
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants.
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# This allows declaration use PowerTools::Data ':all';
|
22
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
|
23
|
|
|
|
|
|
|
# will save memory.
|
24
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw(
|
25
|
|
|
|
|
|
|
connect disconnect status execute count
|
26
|
|
|
|
|
|
|
) ] );
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our @EXPORT = qw(
|
31
|
|
|
|
|
|
|
connect disconnect status execute count
|
32
|
|
|
|
|
|
|
);
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
our $VERSION = '0.04';
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Below is stub documentation for your module. You'd better edit it!
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 NAME
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
PowerTools::Data - Additional Perl tool for Apache::ASP - MySQL database connection
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
use PowerTools::Data;
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Create new object using params
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $db = PowerTools::Data->new(
|
50
|
|
|
|
|
|
|
# Username
|
51
|
|
|
|
|
|
|
username => 'mysql', # default 'root'
|
52
|
|
|
|
|
|
|
# Password
|
53
|
|
|
|
|
|
|
password => 'grendel1981', # default ''
|
54
|
|
|
|
|
|
|
# Database name
|
55
|
|
|
|
|
|
|
database => 'test', # default 'test'
|
56
|
|
|
|
|
|
|
# Hostname
|
57
|
|
|
|
|
|
|
hostname => 'localhost, # default 'localhost';
|
58
|
|
|
|
|
|
|
# Port
|
59
|
|
|
|
|
|
|
port => 3306, # default 3306;
|
60
|
|
|
|
|
|
|
# Protocol compression (0/1)
|
61
|
|
|
|
|
|
|
compression => 1, # default 1;
|
62
|
|
|
|
|
|
|
# DBI's RaiseError (0/1)
|
63
|
|
|
|
|
|
|
errors => 1, # default 1;
|
64
|
|
|
|
|
|
|
# DBI's AutoCommit (0/1)
|
65
|
|
|
|
|
|
|
commit => 1 # default 1;
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
);
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# Create new object using .INI file
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my $db = PowerTools::Data->new(
|
72
|
|
|
|
|
|
|
# Path to .INI file
|
73
|
|
|
|
|
|
|
ini => 'test.ini' # default ''
|
74
|
|
|
|
|
|
|
);
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# Note: You can change .ini extension to other
|
77
|
|
|
|
|
|
|
# Remember to secure choosen extensions name in Your Apache config
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# Connects to database
|
80
|
|
|
|
|
|
|
my $conn = $db->connect;
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# Connection status (0 - FAIL/1 - OK)
|
83
|
|
|
|
|
|
|
my $s = $db->status;
|
84
|
|
|
|
|
|
|
print "STATUS $s\n";
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# MySQL Server info
|
87
|
|
|
|
|
|
|
my $s = $db->{_SERVER_INFO};
|
88
|
|
|
|
|
|
|
print "SERVER $s\n";
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# MySQL Server host info
|
91
|
|
|
|
|
|
|
my $s = $db->{_HOST_INFO};
|
92
|
|
|
|
|
|
|
print "HOST $s\n";
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# Executes SQL statement
|
95
|
|
|
|
|
|
|
my $ex = $db->execute("INSERT INTO test (test_val1,test_val2) VALUES ('a','b')");
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# Items count
|
98
|
|
|
|
|
|
|
my $cn = $db->count;
|
99
|
|
|
|
|
|
|
print "COUNT INSERT $cn\n";
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# Last inserted item
|
102
|
|
|
|
|
|
|
my $lt = $db->last;
|
103
|
|
|
|
|
|
|
print "LAST ITEM $lt\n";
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# Query execute time
|
106
|
|
|
|
|
|
|
my $tk = $db->took;
|
107
|
|
|
|
|
|
|
print "TOOK $tk\n";
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# Parse query result
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
while(!$db->eof) {
|
112
|
|
|
|
|
|
|
my $str = "-> ".$db->field('test_id').", ".$db->field('test_val1').", ".$db->field('test_val2').", ".$db->field('test_val3');
|
113
|
|
|
|
|
|
|
print "$str\n";
|
114
|
|
|
|
|
|
|
$db->movenext;
|
115
|
|
|
|
|
|
|
}
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# Additional tools
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# Get (in MySQL format) current: date ('GET_MYSQL_DATE'), datetime ('GET_MYSQL_DATETIME'), time ('GET_MYSQL_TIME'), timestamp ('GET_MYSQL_TIMESTAMP')
|
120
|
|
|
|
|
|
|
my $cur = $db->tools('GET_MYSQL_TIMESTAMP');
|
121
|
|
|
|
|
|
|
print "$cur\n";
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# Returns time object from MySQL's: date ('RETURN_TIME_DATE'), datetime ('RETURN_TIME_DATETIME'), timestamp ('RETURN_TIME_TIMESTAMP')
|
124
|
|
|
|
|
|
|
my $cur = $db->tools('RETURN_TIME_TIMESTAMP',$cur);
|
125
|
|
|
|
|
|
|
print "$cur\n";
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 AUTHOR
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Piotr Ginalski, Eoffice@gbshouse.comE
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Copyright (C) 2007 by A. U. Thor
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify
|
137
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.8 or,
|
138
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available.
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
our ($_CONN,$_CONN_STATUS,$_CONN_ERROR,$_QUERY,$_QUERY_RESULT,$_QUERY_STATUS,$_RECORD_COUNT,$_SERVER_INFO,$_HOST_INFO,$_LAST_ID,$_COMMIT,$_TIME_TOOK);
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub new {
|
146
|
|
|
|
|
|
|
my $class = shift;
|
147
|
|
|
|
|
|
|
my (%options) = @_;
|
148
|
|
|
|
|
|
|
return bless \%options, $class;
|
149
|
|
|
|
|
|
|
}
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub connect {
|
152
|
|
|
|
|
|
|
my $self = shift;
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
my $db_user = $self->{username} || 'root';
|
155
|
|
|
|
|
|
|
my $db_pass = $self->{password} || '';
|
156
|
|
|
|
|
|
|
my $db_base = $self->{database} || 'test';
|
157
|
|
|
|
|
|
|
my $db_host = $self->{hostname} || 'localhost';
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
my $db_port = $self->{port} || 3306;
|
160
|
|
|
|
|
|
|
my $db_comp = $self->{compression} || 1;
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
my $db_re = $self->{errors} || 1;
|
163
|
|
|
|
|
|
|
my $db_ac = $self->{commit} || 1;
|
164
|
|
|
|
|
|
|
$self->{_COMMIT} = $db_ac;
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
my $db_log = $self->{log} || 0;
|
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
my $ini = $self->{ini};
|
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
if( ($ini) && (-e $ini) ) {
|
171
|
|
|
|
|
|
|
my $conf = ReadINI $ini;
|
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
$db_user = $conf->{mysql}->{username} || 'root';
|
174
|
|
|
|
|
|
|
$db_pass = $conf->{mysql}->{password} || '';
|
175
|
|
|
|
|
|
|
$db_base = $conf->{mysql}->{database} || 'test';
|
176
|
|
|
|
|
|
|
$db_host = $conf->{mysql}->{hostname} || 'localhost';
|
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
$db_port = $conf->{mysql}->{port} || 3306;
|
179
|
|
|
|
|
|
|
$db_comp = $conf->{mysql}->{compression} || 1;
|
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
$db_re = $conf->{mysql}->{errors} || 1;
|
182
|
|
|
|
|
|
|
$db_ac = $conf->{mysql}->{commit} || 1;
|
183
|
|
|
|
|
|
|
$self->{_COMMIT} = $db_ac;
|
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
$db_log = $conf->{mysql}->{log} || 0;
|
186
|
|
|
|
|
|
|
} else {
|
187
|
|
|
|
|
|
|
_error("Can't open INI file");
|
188
|
|
|
|
|
|
|
}
|
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
eval {
|
191
|
|
|
|
|
|
|
my $db_dsn = "DBI:mysql:database=".$db_base.";host=".$db_host.";port=".$db_port.";mysql_compression=".$db_comp;
|
192
|
|
|
|
|
|
|
$self->{_CONN} = DBI->connect($db_dsn,$db_user,$db_pass,{'RaiseError' => $db_re, 'AutoCommit' => $db_ac, 'PrintError' => 1}) or die $DBI::lasth->errstr;
|
193
|
|
|
|
|
|
|
};
|
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
if ($@) {
|
196
|
|
|
|
|
|
|
$self->{_CONN_STATUS} = 0;
|
197
|
|
|
|
|
|
|
$self->{_CONN_ERROR} = $DBI::lasth->errstr;
|
198
|
|
|
|
|
|
|
_error($DBI::lasth->errstr);
|
199
|
|
|
|
|
|
|
} else {
|
200
|
|
|
|
|
|
|
$self->{_CONN_STATUS} = 1;
|
201
|
|
|
|
|
|
|
$self->{_SERVER_INFO} = $self->{_CONN}->{'mysql_serverinfo'};
|
202
|
|
|
|
|
|
|
$self->{_HOST_INFO} = $self->{_CONN}->{'mysql_hostinfo'};
|
203
|
|
|
|
|
|
|
}
|
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
return $self->{_CONN};
|
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
}
|
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub execute {
|
210
|
|
|
|
|
|
|
my $self = shift;
|
211
|
|
|
|
|
|
|
my $query = $_[0];
|
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
if( ($query) && ($self->{_CONN_STATUS} == 1) ) {
|
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
my $t0 = time();
|
216
|
|
|
|
|
|
|
my $Q = substr $query, 0, 6;
|
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
if($Q eq 'SELECT') {
|
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
$self->{'current_record'} = 0;
|
221
|
|
|
|
|
|
|
$self->{_QUERY} = $self->{_CONN}->prepare($query) or die $DBI::lasth->errstr;
|
222
|
|
|
|
|
|
|
$self->{_QUERY}->execute() or die $DBI::lasth->errstr;
|
223
|
|
|
|
|
|
|
$self->{_QUERY_RESULT} = $self->{_QUERY}->fetchall_arrayref({});
|
224
|
|
|
|
|
|
|
$self->{_RECORD_COUNT} = $self->{_QUERY}->rows;
|
225
|
|
|
|
|
|
|
$self->{_QUERY}->finish();
|
226
|
|
|
|
|
|
|
$self->{_QUERY_STATUS} = 1;
|
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
} elsif($Q eq 'INSERT') {
|
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
$self->{_QUERY} = $self->{_CONN}->do($query) or die $DBI::lasth->errstr;
|
231
|
|
|
|
|
|
|
$self->{_RECORD_COUNT} = $self->{_QUERY};
|
232
|
|
|
|
|
|
|
$self->{_LAST_ID} = $self->{_CONN}->{'mysql_insertid'};
|
233
|
|
|
|
|
|
|
$self->{_QUERY_STATUS} = 1;
|
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
} elsif($Q eq 'UPDATE') {
|
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
$self->{_QUERY} = $self->{_CONN}->do($query) or die $DBI::lasth->errstr;
|
238
|
|
|
|
|
|
|
$self->{_RECORD_COUNT} = $self->{_QUERY};
|
239
|
|
|
|
|
|
|
$self->{_LAST_ID} = $self->{_CONN}->{'mysql_insertid'};
|
240
|
|
|
|
|
|
|
$self->{_QUERY_STATUS} = 1;
|
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
} elsif($Q eq 'DELETE') {
|
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
$self->{_QUERY} = $self->{_CONN}->do($query) or die $DBI::lasth->errstr;
|
245
|
|
|
|
|
|
|
$self->{_RECORD_COUNT} = $self->{_QUERY};
|
246
|
|
|
|
|
|
|
$self->{_LAST_ID} = $self->{_CONN}->{'mysql_insertid'};
|
247
|
|
|
|
|
|
|
$self->{_QUERY_STATUS} = 1;
|
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
} else {
|
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
}
|
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
my $t1 = time();
|
254
|
|
|
|
|
|
|
$self->{_TIME_TOOK} = ($t1 - $t0);
|
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
} else {
|
257
|
|
|
|
|
|
|
$self->{_QUERY_STATUS} = 0;
|
258
|
|
|
|
|
|
|
}
|
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
return $self;
|
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
}
|
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
sub took {
|
265
|
|
|
|
|
|
|
my $self = shift;
|
266
|
|
|
|
|
|
|
if($self->{_CONN_STATUS} == 1) {
|
267
|
|
|
|
|
|
|
return sprintf('%.6f',$self->{_TIME_TOOK});
|
268
|
|
|
|
|
|
|
} else {
|
269
|
|
|
|
|
|
|
return undef;
|
270
|
|
|
|
|
|
|
}
|
271
|
|
|
|
|
|
|
}
|
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
sub eof {
|
274
|
|
|
|
|
|
|
my $self = shift;
|
275
|
|
|
|
|
|
|
if($self->{_CONN_STATUS} == 1) {
|
276
|
|
|
|
|
|
|
if($self->{'current_record'} < $self->{_QUERY}->rows) {
|
277
|
|
|
|
|
|
|
return 0;
|
278
|
|
|
|
|
|
|
} else {
|
279
|
|
|
|
|
|
|
return 1;
|
280
|
|
|
|
|
|
|
}
|
281
|
|
|
|
|
|
|
} else {
|
282
|
|
|
|
|
|
|
return 1;
|
283
|
|
|
|
|
|
|
}
|
284
|
|
|
|
|
|
|
}
|
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
sub movenext {
|
287
|
|
|
|
|
|
|
my $self = shift;
|
288
|
|
|
|
|
|
|
if($self->{_CONN_STATUS} == 1) {
|
289
|
|
|
|
|
|
|
if($self->{'current_record'} < $self->{_QUERY}->rows) {
|
290
|
|
|
|
|
|
|
$self->{'current_record'}++;
|
291
|
|
|
|
|
|
|
}
|
292
|
|
|
|
|
|
|
}
|
293
|
|
|
|
|
|
|
return $self;
|
294
|
|
|
|
|
|
|
}
|
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
sub field {
|
297
|
|
|
|
|
|
|
my $self = shift;
|
298
|
|
|
|
|
|
|
if($self->{_CONN_STATUS} == 1) {
|
299
|
|
|
|
|
|
|
my $p = $_[0];
|
300
|
|
|
|
|
|
|
return $self->{_QUERY_RESULT}->[$self->{'current_record'}]->{$p};
|
301
|
|
|
|
|
|
|
}
|
302
|
|
|
|
|
|
|
}
|
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
sub last {
|
305
|
|
|
|
|
|
|
my $self = shift;
|
306
|
|
|
|
|
|
|
return $self->{_LAST_ID};
|
307
|
|
|
|
|
|
|
}
|
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
sub count {
|
310
|
|
|
|
|
|
|
my $self = shift;
|
311
|
|
|
|
|
|
|
if($self->{_RECORD_COUNT} eq '0E0') { $self->{_RECORD_COUNT} = 0; }
|
312
|
|
|
|
|
|
|
if($self->{_RECORD_COUNT} < 0) { $self->{_RECORD_COUNT} = 0; }
|
313
|
|
|
|
|
|
|
return $self->{_RECORD_COUNT};
|
314
|
|
|
|
|
|
|
}
|
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
sub disconnect {
|
317
|
|
|
|
|
|
|
my $self = shift;
|
318
|
|
|
|
|
|
|
if($self->{_CONN_STATUS} == 1) {
|
319
|
|
|
|
|
|
|
$self->{_CONN}->disconnect;
|
320
|
|
|
|
|
|
|
}
|
321
|
|
|
|
|
|
|
return $self;
|
322
|
|
|
|
|
|
|
}
|
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
sub status {
|
325
|
|
|
|
|
|
|
my $self = shift;
|
326
|
|
|
|
|
|
|
return $self->{_CONN_STATUS};
|
327
|
|
|
|
|
|
|
}
|
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
sub tools {
|
330
|
|
|
|
|
|
|
my $self = shift;
|
331
|
|
|
|
|
|
|
my $O = $_[0];
|
332
|
|
|
|
|
|
|
my $V = $_[1];
|
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
if($O eq 'GET_MYSQL_DATE') {
|
335
|
|
|
|
|
|
|
my $t = localtime;
|
336
|
|
|
|
|
|
|
return $t->mysql_date;
|
337
|
|
|
|
|
|
|
} elsif($O eq 'GET_MYSQL_DATETIME') {
|
338
|
|
|
|
|
|
|
my $t = localtime;
|
339
|
|
|
|
|
|
|
return $t->mysql_datetime;
|
340
|
|
|
|
|
|
|
} elsif($O eq 'GET_MYSQL_TIME') {
|
341
|
|
|
|
|
|
|
my $t = localtime;
|
342
|
|
|
|
|
|
|
return $t->mysql_time;
|
343
|
|
|
|
|
|
|
} elsif($O eq 'GET_MYSQL_TIMESTAMP') {
|
344
|
|
|
|
|
|
|
my $t = localtime;
|
345
|
|
|
|
|
|
|
return $t->mysql_timestamp;
|
346
|
|
|
|
|
|
|
} elsif($O eq 'RETURN_TIME_DATE') {
|
347
|
|
|
|
|
|
|
return Time::Piece->from_mysql_date($V);
|
348
|
|
|
|
|
|
|
} elsif($O eq 'RETURN_TIME_DATETIME') {
|
349
|
|
|
|
|
|
|
return Time::Piece->from_mysql_datetime($V);
|
350
|
|
|
|
|
|
|
} elsif($O eq 'RETURN_TIME_TIMESTAMP') {
|
351
|
|
|
|
|
|
|
return Time::Piece->from_mysql_timestamp($V);
|
352
|
|
|
|
|
|
|
}
|
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
}
|
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
sub _error {
|
357
|
|
|
|
|
|
|
my $self = shift;
|
358
|
|
|
|
|
|
|
my $t = $_[0];
|
359
|
|
|
|
|
|
|
return $t;
|
360
|
|
|
|
|
|
|
}
|
361
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
sub _log {
|
363
|
|
|
|
|
|
|
my $self = shift;
|
364
|
|
|
|
|
|
|
my $txt = $_[0];
|
365
|
|
|
|
|
|
|
open(LOG,">>c:\\powertools_data.log");
|
366
|
|
|
|
|
|
|
print LOG $txt,"\n";
|
367
|
|
|
|
|
|
|
close(LOG);
|
368
|
|
|
|
|
|
|
}
|
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
1;
|
371
|
|
|
|
|
|
|
__END__
|