File Coverage

blib/lib/EasyDBAccess.pm
Criterion Covered Total %
statement 58 1116 5.2
branch 0 664 0.0
condition 0 170 0.0
subroutine 6 44 13.6
pod 22 29 75.8
total 86 2023 4.2


line stmt bran cond sub pod time code
1             package EasyDBAccess;
2 1     1   888 use strict;
  1         2  
  1         29  
3 1     1   5 use warnings(FATAL=>'all');
  1         2  
  1         77  
4            
5             our $VERSION = '3.1.2';
6            
7             #===================================
8             #===Module : 43effa740d56a6fd
9             #===Version : 4439fc8192ad837b
10             #===================================
11            
12             #===================================
13             #===Module : Framework::EasyDBAccess
14             #===File : lib/Framework/EasyDBAccess.pm
15             #===Comment : the database access interface
16             #===Require : DBI DBD::Mysql Encode FileHandle
17             #===Require2: EasyHandler
18             #===================================
19            
20             #===================================
21             #===Author : qian.yu ===
22             #===Email : foolfish@cpan.org ===
23             #===MSN : qian.yu@adways.net ===
24             #===QQ : 19937129 ===
25             #===Homepage: www.lua.cn ===
26             #===================================
27            
28             #=======================================
29             #===Author : huang.shuai ===
30             #===Email : huang.shuai@adways.net ===
31             #===MSN : huang.shuai@adways.net ===
32             #=======================================
33            
34             #===3.1.2(2009-03-26): fix bug in batch_insert
35             #===3.1.1(2006-12-27): change document for return value detail
36             #===3.1.0(2006-12-07): fix bug in id() when concurrency
37             #===3.0.9(2006-11-24): add DEFAULT for column default value
38             #===3.0.8(2006-09-22): remove DESTROY function, when set InactiveDestroy true, you should not explicitly call to the disconnect method
39             #===3.0.7(2006-09-13): modified batch_insert
40             #===3.0.6(2006-07-21): change Makefile.PL
41             #===3.0.5(2006-07-20): change META.yml
42             #===3.0.4(2006-07-19): add insert_one_row(), update()
43             #===3.0.3(2006-07-18): modified global constants, document format
44             #===3.0.2(2006-07-13): modified function close(), modified select_one() for bugs
45             #===3.0.1(2006-07-12): u can get err_str from $dba->err_str()
46             #===3.0.0(2006-05-08): merge $param and $ext_option,more document
47             #===2.9.2(2006-04-12): remove relation between $_name_utf8 and EasyTool, add _EasyDBAccess_EasyHandler, use this package instead if EasyTool not load
48             #===2.9.1(2006-04-10): add option $_HIDE_CONN_PARAM, hide conn infomation by default when die, for security
49             #===2.9.0(2006-04-10): replace globe constant modifier from 'my' to 'our'
50             #===2.8.0(2006-04-05): add batch_insert function, add select_array function
51             #===2.7.0(2006-02-13): BUG Fix ,check ^1
52             #===2.6.0(2006-02-07): delete auto_die_handler function, delete install function, add note function
53             #===2.5.0(2006-02-07): new usage: $dba->err_code() $dba->err_code('ER_DUP_ENTRY') $dba->err_code(1062)
54             #===2.4.0(2006-01-03): u can get err_code from $dba->err_code();
55             #===2.2.2(2005-09-07): use socket to connect mysql server
56             #===2.2.2(2005-08-10): change qquote check utf8::is_utf8 before use it,so that the program can run in perl low version
57             #===2.2.1(2005-07-01): rename errcode to err_code, add err_code ER_PARSE_ERROR
58             #===2.2.0(2005-07-01): return use wantarray
59             #===2.1.1(2005-04-28): add errcode function
60             #===2.1.0 : improve id function
61             #===2.0.4 : add once function
62             #===2.0.3 : some small bug fix
63             #===2.0.2 : encoding bug fix
64             #===2.0.1 : so that u can change $_debug in runtime >>my $_debug=1; => our $_debug=1;
65            
66             #===ERR_CODE
67             #NO_ERROR 0
68             #NO_LINE 1
69             #PARAM_ERR 2
70             #CONN_ERR 3
71             #PREPARE_ERR 4
72             #EXEC_ERR 5
73            
74             #===INSTALL for specified function
75             #===ID
76             #CREATE TABLE RES(ATTRIB VARCHAR(255) NOT NULL,ID INT NOT NULL ,PRIMARY KEY (ATTRIB))
77             #CREATE TABLE RES(ATTRIB VARCHAR(255) NOT NULL,ID INT UNSIGNED NOT NULL ,PRIMARY KEY(ATTRIB)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
78             #===SID
79             #CREATE TABLE SID(RECORD_TIME INT UNSIGNED NOT NULL, SID INT UNSIGNED NOT NULL,COMMENT VARCHAR(255) DEFAULT NULL,PRIMARY KEY(RECORD_TIME,SID))
80             #CREATE TABLE SID(RECORD_TIME INT UNSIGNED NOT NULL, SID INT UNSIGNED NOT NULL,COMMENT VARCHAR(255) DEFAULT NULL,PRIMARY KEY(RECORD_TIME,SID)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
81             #===NOTE
82             #CREATE TABLE NOTE(TEXT TEXT NOT NULL, RECORD_TIME INT UNSIGNED NOT NULL)
83             #CREATE TABLE NOTE(TEXT TEXT NOT NULL, RECORD_TIME INT UNSIGNED NOT NULL) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin
84            
85            
86 1     1   3777 use DBI;
  1         30003  
  1         78  
87 1     1   1242 use Encode;
  1         14562  
  1         89  
88 1     1   794 use FileHandle;
  1         12649  
  1         6  
89            
90             #==3.0.3==
91             #our $_pkg_name=__PACKAGE__;
92             #===end===
93 0     0 1   sub foo{1};
94            
95             #==3.0.3==
96             our $_pkg_name;
97             #===end===
98             our $_DEBUG;
99             our $_SETNAMES;
100             our $_HIDE_CONN_PARAM;
101             our $_name_mysql_ver_3;
102             our $_name_mysql_ver_41;
103             our $_name_utf8;
104             our $_dbh_attr_default;
105             our $_mysql_conn_attrib;
106             our $_mysql_error_code_map;
107             our $_ONCE;
108             our $_str_func_new;
109             our $_str_func_id;
110             #==3.0.3==
111             our $_str_func_sid;
112             our $_str_func_die_to_file;
113             our $_str_func_err_str;
114             our $_str_func_err_code;
115             our $_str_func_lookup_err_code;
116             our $_str_func_is_int;
117             #===end===
118             our $_str_func_execute;
119             our $_str_func_select;
120             our $_str_func_select_one;
121             our $_str_func_select_col;
122             our $_str_func_select_row;
123             our $_str_func_select_array;
124             our $_str_new_param_err;
125             our $_str_new_conn_err;
126             our $_str_sql_null_err;
127             our $_str_inline_null_err;
128             our $_str_no_line;
129             our $_str_param_err;
130             our $_str_conn_err;
131             our $_str_prepare_err;
132             our $_str_exec_err;
133             our $_str_dbh_do_err;
134             our $_str_dbh_prepare_err;
135             our $_str_dbh_execute_err;
136             our $_str_dbh_fetchall_arrayref_err;
137             our $_str_dbh_fetchrow_arrayref_err_a;
138             our $_str_dbh_fetchrow_arrayref_err_b;
139             our $_str_dbh_fetchrow_hashref_err_a;
140             our $_str_dbh_fetchrow_hashref_err_b;
141             our $_max_conflict;
142            
143             BEGIN{
144            
145             #==3.0.3==
146 1     1   1143 $_pkg_name=__PACKAGE__;
147             #===end===
148            
149             #===========================================
150             #=== options
151             #===if you set $_DEBUG=false then no "die"
152 1         3 $_DEBUG=1;
153            
154             #===if you set $_SETNAMES=false then won't do set names when connect
155 1         2 $_SETNAMES=1;
156            
157             #===if you set $_HIDE_CONN_PARAM=true, then won't show connect param when die(protect connection password)
158 1         1 $_HIDE_CONN_PARAM=1;
159            
160             #============================================
161            
162             #============================================
163             #===names
164             #===name for mysql version
165 1         2 $_name_mysql_ver_3='3.23';
166 1         2 $_name_mysql_ver_41='4.1';
167            
168             #===use the name of EasyTool if exist
169 1         1 $_name_utf8='utf8';
170             #============================================
171            
172             #============================================
173 1         7 $_dbh_attr_default = {PrintError=>0,RaiseError=>0,LongReadLen=>1048576,FetchHashKeyName=>'NAME_lc',AutoCommit=>1};
174 1         13 $_mysql_conn_attrib= ['host','port','database','mysql_client_found_rows','mysql_compression','mysql_connect_timeout','mysql_read_default_file','mysql_read_default_group','mysql_socket','mysql_ssl','mysql_ssl_client_key','mysql_ssl_client_cert','mysql_ssl_ca_file','mysql_ssl_ca_path','mysql_ssl_cipher','mysql_local_infile'];
175 1         4 $_mysql_error_code_map={
176             ER_DUP_ENTRY=>1062, #Duplicate entry for key
177             ER_NO_SUCH_TABLE=>1146, #No such table
178             ER_PARSE_ERROR=>1064 #SQL string parse error
179             };
180             #============================================
181            
182 1         2 $_ONCE=0;#ignore the next function's error
183            
184 1         1 $_str_func_new='new';
185 1         2 $_str_func_id='id';
186             #==3.0.3==
187 1         1 $_str_func_sid='sid';
188 1         1 $_str_func_die_to_file='die_to_file';
189 1         1 $_str_func_err_str='err_str';
190 1         2 $_str_func_err_code='err_code';
191 1         10 $_str_func_lookup_err_code='_lookup_err_code';
192 1         1 $_str_func_is_int='is_int';
193             #===end===
194 1         2 $_str_func_execute='execute';
195 1         2 $_str_func_select='select';
196 1         1 $_str_func_select_one='select_one';
197 1         2 $_str_func_select_col='select_col';
198 1         1 $_str_func_select_row='select_row';
199 1         15 $_str_func_select_array='select_array';
200            
201 1         2 $_str_new_param_err='only can accept one or two param';
202 1         2 $_str_new_conn_err='connect to database failed';
203 1         1 $_str_sql_null_err='sql string is null';
204 1         1 $_str_inline_null_err='null in inline param';
205 1         2 $_str_no_line='NO_LINE';
206 1         2 $_str_param_err='PARAM_ERR';
207 1         1 $_str_conn_err='CONN_ERR';
208 1         2 $_str_prepare_err='PREPARE_ERR';
209 1         1 $_str_exec_err='EXEC_ERR';
210 1         2 $_str_dbh_do_err='when call $dbh->do, system return fause';
211 1         1 $_str_dbh_prepare_err='when call $dbh->prepare, system return fause';
212 1         2 $_str_dbh_execute_err='when call $dbh->execute, system return fause';
213 1         1 $_str_dbh_fetchall_arrayref_err='when call $sth->fetchall_arrayref, system return fause, maybe u use select on a none select sql';
214 1         1 $_str_dbh_fetchrow_arrayref_err_a='when call $sth->fetchrow_hashref, system return fause, maybe u use select on a none select sql';
215 1         2 $_str_dbh_fetchrow_arrayref_err_b='when call $dbh->fetchrow_arrayref, system return fause, maybe u try to get one row from a result set with no row in it';
216 1         2 $_str_dbh_fetchrow_hashref_err_a='when call $sth->fetchrow_hashref, system return fause, maybe u use select on a none select sql';
217 1         1 $_str_dbh_fetchrow_hashref_err_b='when call $sth->fetchrow_hashref, system return fause, maybe u try to get one row from a result set with no row in it';
218            
219 1         16517 $_max_conflict=10;
220            
221             }
222            
223             sub new {
224 0     0 1   my $class = shift;
225 0           my ($param,$option);
226            
227 0 0         my $once=($_ONCE==1)?1:0;
228 0 0         if($once){$_ONCE=0 if $_ONCE==1;};
  0 0          
229            
230 0           my $param_count=scalar(@_);
231 0 0         if($param_count==1){
    0          
232 0           ($param)=@_;
233             }elsif($param_count==2){
234 0           ($param,$option)=@_;
235             }else{
236 0           my ($err_code,$err_detail)=(2,'');
237 0           my $sys_err='';
238 0 0         my $param="ParamInfo :\n".($_HIDE_CONN_PARAM?'connect param is hide for security':_dump([@_]))."\n";
239 0           my $caller='';
240 0           for(my $i=0;;$i++){
241 0           my $ra_caller_info=[caller($i)];
242 0 0         if(scalar(@$ra_caller_info)==0){last;}
  0            
243             else{
244 0           $caller="\t$ra_caller_info->[1] LINE ".sprintf('%04s',$ra_caller_info->[2]).": $ra_caller_info->[3]\n$caller";
245             }
246             }
247 0           $caller="CallerInfo:\n$caller";
248 0           $err_detail="$_pkg_name\:\:$_str_func_new\(\) throw $_str_param_err\nHelpNote : $_str_new_param_err\n$sys_err$param$caller\n";
249 0 0 0       if($_DEBUG&&!$once){
250 0           CORE::die $err_detail;
251             }
252 0 0         return wantarray?(undef,$err_code,$err_detail,$_pkg_name):undef;
253             }
254            
255 0 0         if(!defined($option)){$option={};}
  0            
256             #===make a copy of $param, merge two param
257 0           $param={%$param,%$option};
258            
259 0           my $self = bless {},$class;
260 0           my $dbh;
261 0   0       my $type=delete $param->{'type'}||'mysql';
262 0           my $die_handler=$param->{die_handler};
263            
264 0 0         if(!defined($die_handler)){
265 0 0         if(defined($param->{err_file})){
266 0 0         if(defined(&EasyHandler::foo)){
267 0           $die_handler=EasyHandler->new(\&die_to_file,[$param->{err_file}]);
268             }else{
269 0           $die_handler=_EasyDBAccess_EasyHandler->new(\&die_to_file,[$param->{err_file}]);
270             }
271             }
272             }
273            
274 0           my ($version,$ver,$unicode,$encoding);
275            
276 0 0         if($type eq 'mysql'){
  0            
277 0           my $usr=_IFNULL(delete($param->{usr}),'root');
278 0           my $pass=_IFNULL(delete($param->{pass}),'');
279 0           my $dsn;
280 0           my $socket=delete($param->{socket});
281 0 0         if(defined($socket)){
282 0           $encoding=_IFNULL(delete($param->{encoding}),$_name_utf8);
283 0           $unicode=_IFNULL(delete($param->{unicode}),0);
284 0           $version=delete $param->{version};
285 0           my $extra_conn_attrib='';
286 0           foreach(@$_mysql_conn_attrib){
287 0 0         if(defined($param->{$_})){
288 0           $extra_conn_attrib.=$_.'='.(delete $param->{$_}).';';
289             }
290             }
291 0           $dsn ='DBI:mysql:'.$extra_conn_attrib.'mysql_socket='.$socket;
292             }else{
293 0           my $host=_IFNULL(delete($param->{host}),'127.0.0.1');
294 0           my $port=_IFNULL(delete($param->{port}),3306);
295 0           $encoding=_IFNULL(delete($param->{encoding}),$_name_utf8);
296 0           $unicode=_IFNULL(delete($param->{unicode}),0);
297 0           $version=delete $param->{version};
298 0           my $extra_conn_attrib='';
299 0           foreach(@$_mysql_conn_attrib){
300 0 0         if(defined($param->{$_})){
301 0           $extra_conn_attrib.=$_.'='.(delete $param->{$_}).';';
302             }
303             }
304 0           $dsn ='DBI:mysql:host='.$host.';'.$extra_conn_attrib.'port='.$port;
305             }
306            
307             #===merge default attrib and user set attrib
308 0           my $attr={%$_dbh_attr_default};
309 0           while(my ($k,$v)=each %$param){$attr->{$k}=$v;}
  0            
310            
311             #===$param now no use at all,so destroy it
312 0           undef %$param;
313            
314             #===try to connect
315 0           $dbh = DBI->connect($dsn,$usr,$pass,$attr);
316            
317             #===connect to database failed
318 0 0         if(!defined($dbh)){
319 0           my ($err_code,$err_detail)=(3,'');
320 0 0         my $sys_err=defined(&DBI::errstr)?"ErrString : ".&DBI::errstr."\n":'';
321 0 0         my $param="ParamInfo :\n".($_HIDE_CONN_PARAM?'connect param is hide for security':_dump([@_]))."\n";
322 0           my $caller='';
323 0           for(my $i=0;;$i++){
324 0           my $ra_caller_info=[caller($i)];
325 0 0         if(scalar(@$ra_caller_info)==0){last;}
  0            
326             else{
327 0           $caller="\t$ra_caller_info->[1] LINE ".sprintf('%04s',$ra_caller_info->[2]).": $ra_caller_info->[3]\n$caller";
328             }
329             }
330 0           $caller="CallerInfo:\n$caller";
331 0           $err_detail="$_pkg_name\:\:$_str_func_new\(\) throw $_str_conn_err\nHelpNote : $_str_new_conn_err\n$sys_err$param$caller\n";
332 0 0 0       if($_DEBUG&&!$once){
333 0 0         if(defined($die_handler)){
334 0           $die_handler->execute($err_code,$err_detail,$_pkg_name);
335             }else{
336 0           CORE::die $err_detail;
337             }
338             }
339 0 0         return wantarray?(undef,$err_code,$err_detail,$_pkg_name):undef;
340             }
341            
342             #===get database version
343 0 0         if(!defined($version)){
344 0           $version=$dbh->selectrow_arrayref("SHOW VARIABLES LIKE 'VERSION'")->[1];
345             }
346 0           $ver=substr($version,0,3);
347            
348             #===if version>4.1 then set charset
349 0 0 0       if($ver>=$_name_mysql_ver_41&&$_SETNAMES){
350 0           $dbh->do("SET NAMES '$encoding'");
351             }
352             }else{CORE::die "$_pkg_name\:\:$_str_func_new\(\) unknow database type";}
353            
354 0           $self->{dbh}=$dbh;
355 0           $self->{type}=$type;
356 0           $self->{ver}=$ver;
357 0           $self->{version}=$version;
358 0           $self->{die_handler}=$die_handler;
359 0           $self->{unicode}=$unicode;
360 0           $self->{encoding}=$encoding;
361             #==3.0.1==
362 0           $self->{err_str}=undef;
363             #===end===
364 0           $self->{err_code}=undef;
365 0           $self->{once}=0;#ignore the next function's error
366 0 0         return wantarray?($self,0,undef,$_pkg_name):$self;
367             }
368            
369 0     0 1   sub dbh{return $_[0]->{dbh};}
370             #==3.0.2==
371             #sub close{undef $_[0];return 1;}
372             sub close{
373 0 0   0 1   if(defined $_[0]){
374 0 0         if(defined($_[0]->{dbh})){
375 0           $_[0]->{dbh}->disconnect();
376 0           $_[0]->{dbh}=undef;
377             }
378 0           undef $_[0];
379             }
380 0           return 1;
381             }
382             #===end===
383 0     0 1   sub type{return $_[0]->{type};}
384             sub once{
385 0     0 1   my ($self)=@_;
386 0 0         if(ref $self eq $_pkg_name){
387 0           $self->{once}=1;
388             }else{
389 0           $_ONCE=1;
390             }
391             }
392            
393             sub id{
394 0     0 1   my $self=shift;
395 0 0         if($self->{type} eq 'mysql'){
  0            
396 0 0 0       if(defined($_[1])&&($_[1]>1)){
397 0 0         my $rc=$self->{dbh}->do('UPDATE RES SET ID=LAST_INSERT_ID(ID+?) WHERE ATTRIB=?;',undef,$_[1],defined($_[0])?$_[0]:'ANON');
398 0 0         if($rc==0){
399 0 0         $self->{dbh}->do('INSERT INTO RES(ATTRIB,ID) VALUES(?,0);',undef,defined($_[0])?$_[0]:'ANON');
400 0 0         $self->{dbh}->do('UPDATE RES SET ID=LAST_INSERT_ID(ID+?) WHERE ATTRIB=?;',undef,$_[1],defined($_[0])?$_[0]:'ANON');
401             }
402 0           my $id=$self->{dbh}->selectrow_arrayref('SELECT LAST_INSERT_ID();')->[0];
403 0           return $id;
404             }
405 0 0         my $rc=$self->{dbh}->do('UPDATE RES SET ID=LAST_INSERT_ID(ID+1) WHERE ATTRIB=?;',undef,defined($_[0])?$_[0]:'ANON');
406 0 0         if($rc==0){
407             #==3.1.0==
408             # $self->{dbh}->do('INSERT INTO RES(ATTRIB,ID) VALUES(?,1);',undef,defined($_[0])?$_[0]:'ANON');
409             # return 1;
410 0 0         $self->{dbh}->do('INSERT INTO RES(ATTRIB,ID) VALUES(?,0);',undef,defined($_[0])?$_[0]:'ANON');
411 0 0         $self->{dbh}->do('UPDATE RES SET ID=LAST_INSERT_ID(ID+1) WHERE ATTRIB=?;',undef,defined($_[0])?$_[0]:'ANON');
412             #==end==
413             }
414 0           my $id=$self->{dbh}->selectrow_arrayref('SELECT LAST_INSERT_ID();')->[0];
415 0           return $id;
416             }else{CORE::die "$_pkg_name\:\:$_str_func_id\(\) unknow database type;";}
417             }
418            
419            
420             sub sid{
421 0     0 1   my $self=shift;
422 0 0         if($self->{type} eq 'mysql'){
  0            
423 0           my ($now,$sid,$succ)=(CORE::time(),undef,undef);
424 0           for(1..$_max_conflict){
425 0           my $rc=int $self->{dbh}->do('INSERT IGNORE INTO SID(RECORD_TIME,SID,COMMENT)VALUES(?,LAST_INSERT_ID(FLOOR(RAND()*4294967296)+1),?)',undef,$now,$_[0]);
426 0 0         if($rc==1){
427 0           $sid=$self->{dbh}->selectrow_arrayref('SELECT LAST_INSERT_ID()')->[0];
428 0           $succ=1;
429 0           last;
430             }else{
431 0           next;
432             }
433             }
434 0 0         if($succ){
435 0           return sprintf("%08x%08x",$now,$sid);
436             }else{
437             #==3.0.3==
438             # CORE::die $_pkg_name."::sid: too much conflict";
439 0           CORE::die "$_pkg_name\:\:$_str_func_sid\(\) too much conflict";
440             #===end===
441             }
442             #==3.0.3==
443             # }else{CORE::die "$_pkg_name\:\:$_str_func_id\(\) unknow database type;";}
444             }else{CORE::die "$_pkg_name\:\:$_str_func_sid\(\) unknow database type;";}
445             #===end===
446             }
447            
448             sub sid_info{
449 0     0 0   my $self=shift;
450 0 0 0       if(defined($_[0])&&(ref($_[0]) eq '')&&($_[0]=~/^([0-9a-fA-F]{8})([0-9a-fA-F]{8})$/)){
      0        
451 0           my $rtn=$self->select_row('SELECT RECORD_TIME,SID,COMMENT FROM SID WHERE RECORD_TIME=? AND SID=?',[hex $1,hex $2]);
452 0           return $rtn;
453             }
454 0           return undef;
455             }
456            
457             sub note{
458 0     0 1   my $self=shift;
459 0           return $self->{dbh}->do('INSERT INTO NOTE(TEXT,RECORD_TIME) VALUES(?,?);',undef,$_[0],CORE::time());
460             }
461            
462             sub _replace {
463 0     0     while(my($k,$v)=each %{$_[1]}){
  0            
464 0 0         if(!defined($v)){return 0;}
  0            
465 0           $_[0]=~s/\Q%$k\E/$v/g;
466             }
467 0           return 1;
468             }
469            
470             sub _encode{
471 0 0   0     if(defined($_[2])){
472 0           $_[0]=Encode::encode($_[2],$_[0]);
473 0           my $ra=[];
474 0           foreach(@{$_[1]}){
  0            
475 0 0         push @$ra,utf8::is_utf8($_)?Encode::encode($_[2],$_):$_;
476             }
477 0           $_[1]=$ra;
478             }else{
479 0           &utf8::encode($_[0]);
480 0           my $ra=[];
481 0           foreach(@{$_[1]}){
  0            
482 0 0         if(utf8::is_utf8($_)){&utf8::encode($_);}
  0            
483 0           push @$ra,$_;
484             }
485 0           $_[1]=$ra;
486             }
487             }
488            
489             sub _decode{
490 0     0     my $ref=ref $_[0];
491 0 0         if($ref eq 'ARRAY'){
    0          
492 0           foreach (@{$_[0]}){
  0            
493 0           _decode($_,$_[1]);
494             }
495             }elsif($ref eq 'HASH'){
496 0           foreach (keys(%{$_[0]})){
  0            
497 0           my $k=$_;
498 0           _decode($k,$_[1]);
499 0           my $v=delete $_[0]->{$_};
500 0           _decode($v,$_[1]);
501 0           $_[0]->{$k}=$v;
502             }
503             }else{
504 0 0         if(defined($_[1])){
505 0           $_[0]=Encode::decode($_[1],$_[0]);
506             }else{
507 0           &utf8::decode($_[0]);
508             }
509             }
510             }
511            
512             # put a string value in double quotes
513             sub qquote {
514 0     0 0   local($_) = shift;
515 0           s/([\\\"\@\$])/\\$1/g;
516 0 0 0       s/([^\x00-\x7f])/sprintf("\\x{%04X}",ord($1))/eg if (defined(&utf8::is_utf8) && utf8::is_utf8($_));
  0            
517 0 0         return qq("$_") unless
518             /[^ !"\#\$%&'()*+,\-.\/0-9:;<=>?\@A-Z[\\\]^_`a-z{|}~]/; # fast exit
519 0           s/([\a\b\t\n\f\r\e])/{
520 0           "\a" => "\\a","\b" => "\\b","\t" => "\\t","\n" => "\\n",
521             "\f" => "\\f","\r" => "\\r","\e" => "\\e"}->{$1}/eg;
522 0           s/([\0-\037\177])/'\\x'.sprintf('%02X',ord($1))/eg;
  0            
523 0           s/([\200-\377])/'\\x'.sprintf('%02X',ord($1))/eg;
  0            
524 0           return qq("$_");
525             }
526            
527             sub _dump{
528 0     0     my $max_line=80;
529 0           my $param_count=scalar(@_);
530 0           my ($flag,$str1,$str2);
531 0 0         if($param_count==1){
532 0           my $data=$_[0];
533 0           my $type=ref $data;
534 0 0         if($type eq 'ARRAY'){
    0          
    0          
535 0           my $strs=[];
536 0           foreach(@$data){push @$strs,_dump($_);}
  0            
537            
538 0           $str1='[';
539 0           $flag=0;
540 0           foreach(@$strs){$str1.=$_.', ';$flag=1;}
  0            
  0            
541 0 0         if($flag==1){chop($str1);chop($str1);}
  0            
  0            
542 0           $str1.=']';
543            
544 0           $str2='[';
545 0           foreach(@$strs){s/\n/\n\x20\x20/g;$str2.="\n\x20\x20".$_.',';}
  0            
  0            
546 0           $str2.="\n]";
547            
548 0 0         return length($str1)>$max_line?$str2:$str1;
549             }elsif($type eq 'HASH'){
550 0           my $strs=[];
551 0           foreach(keys(%$data)){push @$strs,[qquote($_),_dump($data->{$_})];}
  0            
552            
553 0           $str1='{';
554 0           $flag=0;
555 0           foreach(@$strs){$str1.="$_->[0] => $_->[1], ";$flag=1;}
  0            
  0            
556 0 0         if($flag==1){chop($str1);chop($str1);}
  0            
  0            
557 0           $str1.='}';
558            
559 0           $str2='{';
560 0           foreach(@$strs){ $_->[1]=~s/\n/\n\x20\x20/g;
  0            
561 0           $str2.="\n\x20\x20$_->[0] => $_->[1],";}
562 0           $str2.="\n}";
563            
564 0 0         return length($str1)>$max_line?$str2:$str1;
565             }elsif($type eq ''){
566 0           $flag=0;
567 0 0         if(!defined($data)){return 'undef'};
  0            
568 0 0         eval{if($data eq int $data){$flag=1;}};
  0            
  0            
569 0 0         if($@){undef $@;}
  0            
570 0 0         if($flag==0){return qquote($data);}
  0 0          
  0            
571             elsif($flag==1){return $data;}
572             }else{
573 0           return ''.$data;
574             }
575             }else{
576 0           my $strs=[];
577 0           foreach(@_){push @$strs,_dump($_);}
  0            
578            
579 0           $str1='(';
580 0           $flag=0;
581 0           foreach(@$strs){$str1.=$_.', ';$flag=1;}
  0            
  0            
582 0 0         if($flag==1){chop($str1);chop($str1);}
  0            
  0            
583 0           $str1.=')';
584            
585 0           $str2='(';
586 0           foreach(@$strs){s/\n/\n\x20\x20/g;$str2.="\n\x20\x20".$_.',';}
  0            
  0            
587 0           $str2.="\n)";
588            
589 0 0         return length($str1)>$max_line?$str2:$str1;
590             }
591             }
592            
593             sub _IFNULL{
594 0 0   0     defined($_[0])?$_[0]:$_[1];
595             }
596            
597             sub build_array{
598 0     0 1   my ($filter,$hash,$array)=@_;
599 0           my $ra=[];
600            
601             #^1
602             #===BUG,fixed in 2.7.0
603             #$array=defined($array)?$array=[@$array]:[];
604             #^1 END
605            
606 0 0         $array=defined($array)?[@$array]:[];
607            
608 0           my $err_code=0;
609 0           foreach(@$filter){
610 0 0 0       if(defined($_)&&($_ ne '?')){
611 0 0         if(exists($hash->{$_})){
612 0           push @$ra,$hash->{$_};
613             }else{
614 0           $err_code=1;
615 0           push @$ra,undef;
616             }
617             }else{
618 0           push @$ra,shift @$array;
619             }
620             }
621 0 0         return wantarray ? ($ra,$err_code):$ra;
622             }
623            
624             sub build_update{
625 0     0 1   my ($filter,$hash)=@_;;
626 0           my $str='';
627 0           my $ra_bind_param=[];
628 0           my $flag=0;
629 0           foreach(@$filter){
630 0           $_=lc($_);
631 0 0         if(exists($hash->{$_})){
632 0           push @$ra_bind_param,$hash->{$_};
633 0           $str.=uc($_).'=?,';
634 0           $flag++;
635             }
636             }
637 0           my $str2=$str;
638 0 0         if($flag!=0){chop($str2)};
  0            
639 0 0         return wantarray ? ($str2,$ra_bind_param,$flag,$str):$str;
640             }
641            
642             sub batch_insert{
643 0     0 1   my $self=shift;
644 0           my ($sql_str,$values_tmpl,$values,$max_count)=@_;
645            
646 0           my $values_str='';my $bind_param=[];my $c=0;
  0            
  0            
647 0           my $item_count=scalar(@$values);
648             #==3.1.2==
649             #if ($item_count==0){return 1;}
650 0 0         if ($item_count==0){return wantarray?(1,0,undef,$_pkg_name):1;}
  0 0          
651             #==end==
652            
653 0 0         if(!defined($max_count)){$max_count=1;}
  0            
654 0           for(my $i=0;$i<$item_count;$i++ ){
655             #==3.0.9==
656 0           my $tmp_tmpl = $values_tmpl;
657 0           my $posi = -1;
658 0           for(my $j=0; $j<@{$values->[$i]}; ++$j){
  0            
659 0           $posi = index($tmp_tmpl, '?', $posi + 1);
660 0 0         if (DEFAULT($values->[$i]->[$j])){
661 0           substr($tmp_tmpl, $posi, 1, 'DEFAULT');
662             }
663             }
664 0           $values_str.=$tmp_tmpl.',';
665 0           my $values_i = [];
666 0           for(my $j=0; $j<@{$values->[$i]}; ++$j){
  0            
667 0 0         if (!DEFAULT($values->[$i]->[$j])){
668 0           push @$values_i, $values->[$i]->[$j];
669             }
670             }
671 0           push @$bind_param,@$values_i;
672             #===end===
673 0           $c++;
674 0 0         if($c>=$max_count){
675 0           my $s=$sql_str;
676 0           chop($values_str);
677 0           $s=~s/\%V/$values_str/g;
678 0           $self->{dbh}->do($s,undef,@$bind_param);
679             #==3.0.7==
680 0 0         if($self->{dbh}->err){
681 0           my $err_detail;
682 0 0         my $sys_err=defined($self->{dbh}->errstr)?"ErrString : ".$self->{dbh}->errstr."\n":'';
683 0           my $param="ParamInfo :\n"._dump([$s,@$bind_param])."\n";
684 0           my $caller='';
685 0           for(my $i=0;;$i++){
686 0           my $ra_caller_info=[caller($i)];
687 0 0         if(scalar(@$ra_caller_info)==0){last;}
  0            
688             else{
689 0           $caller="\t$ra_caller_info->[1] LINE ".sprintf('%04s',$ra_caller_info->[2]).": $ra_caller_info->[3]\n$caller";
690             }
691             }
692 0           $caller="CallerInfo:\n$caller";
693 0           $err_detail="$_pkg_name\:\:batch_insert\(\) throw $_str_exec_err\nHelpNote : $_str_dbh_do_err\n$sys_err$param$caller\n";
694 0 0         return wantarray?(0,5,$err_detail,$_pkg_name):0;
695             }
696             #===end===
697 0           $values_str='';$c=0;$bind_param=[];
  0            
  0            
698             }
699             }
700            
701 0 0         if($c>0){
702 0           my $s=$sql_str;
703 0           chop($values_str);
704 0           $s=~s/\%V/$values_str/g;
705 0           $self->{dbh}->do($s,undef,@$bind_param);
706             #==3.0.7==
707 0 0         if($self->{dbh}->err){
708 0           my $err_detail;
709 0 0         my $sys_err=defined($self->{dbh}->errstr)?"ErrString : ".$self->{dbh}->errstr."\n":'';
710 0           my $param="ParamInfo :\n"._dump([$s,@$bind_param])."\n";
711 0           my $caller='';
712 0           for(my $i=0;;$i++){
713 0           my $ra_caller_info=[caller($i)];
714 0 0         if(scalar(@$ra_caller_info)==0){last;}
  0            
715             else{
716 0           $caller="\t$ra_caller_info->[1] LINE ".sprintf('%04s',$ra_caller_info->[2]).": $ra_caller_info->[3]\n$caller";
717             }
718             }
719 0           $caller="CallerInfo:\n$caller";
720 0           $err_detail="$_pkg_name\:\:batch_insert\(\) throw $_str_exec_err\nHelpNote : $_str_dbh_do_err\n$sys_err$param$caller\n";
721 0 0         return wantarray?(0,5,$err_detail,$_pkg_name):0;
722             }
723             #===end===
724             }
725            
726             #==3.0.7==
727             # return 1;
728 0 0         return wantarray?(1,0,undef,$_pkg_name):1;
729             #===end===
730             }
731            
732             #==3.0.4==
733             #===wang.yezhuo add start===
734            
735             sub insert_one_row {
736 0     0 1   my $self = shift;
737 0           my ($sql, $filter, $rh_data, $ra) = @_;
738            
739 0           my $ra_param = build_array($filter, $rh_data, $ra);
740            
741 0           return $self->execute($sql, $ra_param);
742             }
743            
744             sub update {
745 0     0 1   my $self = shift;
746 0           my ($sql, $filter, $rh_data, $ra_param) = @_;
747            
748 0           my ($item_str, $item_bind_param, $flag, $item_str2) = build_update($filter, $rh_data);
749            
750 0           return $self->execute($sql, [@$item_bind_param, @$ra_param], {ITEM => $item_str, COMMAITEM => $item_str2});
751             }
752            
753             #===wang.yezhuo add end===
754             #===end===
755            
756             sub die_to_file{
757 0     0 0   my $file_path= shift;
758 0           my ($err_pkg,$err_code,$err_detail,$record_time)=(undef,undef,undef,CORE::time);
759 0           my $param_count=scalar(@_);
760 0 0         if($param_count==1){
    0          
    0          
761 0           ($err_detail)=@_;
762             }elsif($param_count==3){
763 0           ($err_code,$err_detail,$err_pkg)=@_;
764             }elsif($param_count==4){
765 0           ($err_code,$err_detail,$err_pkg,$record_time)=@_;
766             }else{
767             #==3.0.3==
768             # CORE::die "die_to_file param error;";
769 0           CORE::die "$_pkg_name\:\:$_str_func_die_to_file\(\) param error;";
770             #===end===
771             }
772            
773 0           $_=[localtime($record_time)];
774 0           my $prefix="#####".sprintf('%04s-%02s-%02s %02s:%02s:%02s',$_->[5]+1900,$_->[4]+1,$_->[3],$_->[2],$_->[1],$_->[0])."\n";
775            
776 0           my $result=append_file($file_path,$prefix.$err_detail."\n");
777 0 0         if($result){
778             #log succ
779 0           CORE::die;
780             }else{
781             #==3.0.3==
782             # CORE::die($_pkg_name.'::_lookup_err_code: param count should be 1');
783 0           CORE::die("$_pkg_name\:\:$_str_func_die_to_file\(\) param count should be 1");
784             #===end===
785             }
786             }
787            
788             #==3.0.1==
789             sub err_str{
790 0     0 1   my $param_count=scalar(@_);
791 0 0         if($param_count==1){
792 0           return $_[0]->{err_str};
793             }else{
794 0           CORE::die("$_pkg_name\:\:$_str_func_err_str\(\) param count should be 1");
795             }
796             }
797             #===end===
798            
799             sub err_code{
800 0     0 1   my $param_count=scalar(@_);
801 0 0         if($param_count==1){
    0          
802 0           return $_[0]->{err_code};
803             }elsif($param_count==2){
804 0   0       return defined($_[0]->{err_code})&&$_[0]->{err_code}==&_lookup_err_code($_[1]);
805             }else{
806             #==3.0.3==
807             # CORE::die($_pkg_name.'::_lookup_err_code: param count should be 1 or 2');
808 0           CORE::die("$_pkg_name\:\:$_str_func_err_code\(\) param count should be 1 or 2");
809             #===end===
810             }
811             }
812            
813             sub _lookup_err_code{
814 0     0     my $param_count=scalar(@_);
815 0 0         if($param_count==1){
816 0           local $_=$_[0];
817 0 0         if(&is_id($_)){
818 0           return int $_;
819             }else{
820 0           return $_mysql_error_code_map->{$_};
821             }
822             }else{
823             #==3.0.3==
824             # CORE::die($_pkg_name.'::_lookup_err_code: param count should be 1');
825 0           CORE::die("$_pkg_name\:\:$_str_func_lookup_err_code\(\) param count should be 1");
826             #===end===
827             }
828             }
829            
830             sub is_int{
831 0     0 0   my $param_count=scalar(@_);
832 0 0         my ($str,$num,$max,$min)=(exists $_[0]?$_[0]:$_,undef,undef,undef);
833 0 0 0       if($param_count==1||$param_count==2||$param_count==3){
      0        
834 0           eval{$num=int($str);};
  0            
835 0 0         if($@){undef $@;return defined(&_name_false)?&_name_false:'';}
  0 0          
  0            
836 0 0         if($num ne $str){return defined(&_name_false)?&_name_false:'';}
  0 0          
837 0 0         if($param_count==1){
    0          
    0          
838 0           $max=2147483648;$min=-2147483648;
  0            
839             }elsif($param_count==2){
840 0           $max=2147483648;$min=$_[1];
  0            
841             }elsif($param_count==3){
842 0           $max=$_[2];$min=$_[1];
  0            
843             }else{
844             #==3.0.3==
845             # CORE::die 'is_int: BUG!';
846 0           CORE::die "$_pkg_name\:\:$_str_func_is_int\(\) BUG!";
847             #===end===
848             }
849 0 0 0       if((!defined($min)||$num>=$min)&&(!defined($max)||$num<$max)){
      0        
      0        
850 0 0         return defined(&_name_true)?&_name_true:1;
851             }else{
852 0 0         return defined(&_name_false)?&_name_false:'';
853             }
854             }else{
855             #==3.0.3==
856             # CORE::die((defined(&_name_pkg_name)?&_name_pkg_name.'::':'').'is_int: param count should be 1, 2 or 3');
857 0 0         CORE::die((defined(&_name_pkg_name)?&_name_pkg_name.'::':'')."$_str_func_is_int\(\) param count should be 1, 2 or 3");
858             #===end===
859             }
860             }
861            
862             sub is_id{
863 0     0 0   return is_int(shift,1,4294967296);
864             }
865            
866             sub append_file{
867 0     0 0   my ($file_path,$data)=@_;
868 0           my $fh=FileHandle->new($file_path,'a');
869 0 0         if(!defined($fh)){return undef};
  0            
870 0           $fh->syswrite($data);
871 0           $fh->close();
872             }
873            
874             #==3.0.8==
875             #when set InactiveDestroy true, you should not explicitly call to the disconnect method
876             #DESTROY{
877             # if(defined($_[0]->{dbh})){
878             # $_[0]->{dbh}->disconnect();
879             # undef $_[0]->{dbh};
880             # }
881             #}
882             #===end===
883            
884             sub execute{
885 0     0 1   my $self=shift;
886 0           my ($sql_str,$bind_param,$inline_param)=@_;
887 0 0 0       if(defined($bind_param)&&(ref($bind_param) eq 'ARRAY')){
    0 0        
888             }elsif(defined($bind_param)&&(ref($bind_param) eq 'HASH')){
889 0           $inline_param=$bind_param;
890 0           $bind_param=[];
891             }else{
892 0           $bind_param=[];
893             }
894 0           my $succ=1;
895            
896 0 0 0       my $once=($_ONCE==1||$self->{once}==1)?1:0;
897 0 0         if($once){$_ONCE=0 if $_ONCE==1;$self->{once}=0 if $self->{once}==1};
  0 0          
  0 0          
898             #==3.0.1==
899 0 0         $self->{err_str}=undef if defined($self->{err_str});;
900             #===end===
901 0 0         $self->{err_code}=undef if defined($self->{err_code});
902            
903 0 0         if(!defined($sql_str)){
904 0           my ($err_code,$err_detail,$die_handler)=(2,'',$self->{die_handler});
905 0           my $sys_err='';
906 0           my $param="ParamInfo :\n"._dump([@_])."\n";
907 0           my $caller='';
908 0           for(my $i=0;;$i++){
909 0           my $ra_caller_info=[caller($i)];
910 0 0         if(scalar(@$ra_caller_info)==0){last;}
  0            
911             else{
912 0           $caller="\t$ra_caller_info->[1] LINE ".sprintf('%04s',$ra_caller_info->[2]).": $ra_caller_info->[3]\n$caller";
913             }
914             }
915 0           $caller="CallerInfo:\n$caller";
916 0           $err_detail="$_pkg_name\:\:$_str_func_execute\(\) throw $_str_param_err\nHelpNote : $_str_sql_null_err\n$sys_err$param$caller\n";
917 0 0 0       if($_DEBUG&&!$once){
918 0 0         if(defined($die_handler)){
919 0           $die_handler->execute($err_code,$err_detail,$_pkg_name);
920             }else{
921 0           CORE::die $err_detail;
922             }
923             }
924 0 0         return wantarray?(undef,$err_code,$err_detail,$_pkg_name):undef;
925             }
926            
927 0 0         if(defined($inline_param)){
928 0           $succ=_replace($sql_str,$inline_param);
929             };
930            
931 0 0         if(!$succ){
932 0           my($err_code,$err_detail,$die_handler)=(2,'',$self->{die_handler});
933 0           my $sys_err='';
934 0           my $param="ParamInfo :\n"._dump([@_])."\n";
935 0           my $caller='';
936 0           for(my $i=0;;$i++){
937 0           my $ra_caller_info=[caller($i)];
938 0 0         if(scalar(@$ra_caller_info)==0){last;}
  0            
939             else{
940 0           $caller="\t$ra_caller_info->[1] LINE ".sprintf('%04s',$ra_caller_info->[2]).": $ra_caller_info->[3]\n$caller";
941             }
942             }
943 0           $caller="CallerInfo:\n$caller";
944 0           $err_detail="$_pkg_name\:\:$_str_func_execute\(\) throw $_str_param_err\nHelpNote : $_str_inline_null_err\n$sys_err$param$caller\n";
945 0 0 0       if($_DEBUG&&!$once){
946 0 0         if(defined($die_handler)){
947 0           $die_handler->execute($err_code,$err_detail,$_pkg_name);
948             }else{
949 0           CORE::die $err_detail;
950             }
951             }
952 0 0         return wantarray?(undef,$err_code,$err_detail,$_pkg_name):undef;
953             }
954             #==3.0.9==
955 0           my $tmp_tmpl = $sql_str;
956 0           my $posi = -1;
957 0           for(my $j=0; $j<@$bind_param; ++$j){
958 0           $posi = index($tmp_tmpl, '?', $posi + 1);
959 0 0         if (DEFAULT($bind_param->[$j])){
960 0           substr($tmp_tmpl, $posi, 1, 'DEFAULT');
961             }
962             }
963 0           $sql_str=$tmp_tmpl;
964 0           my $values_i = [];
965 0           for(my $j=0; $j<@$bind_param; ++$j){
966 0 0         if (!DEFAULT($bind_param->[$j])){
967 0           push @$values_i, $bind_param->[$j];
968             }
969             }
970 0           $bind_param = $values_i;
971             #===end===
972            
973 0           my $unicode=$self->{unicode};
974 0 0         my $dst_encoding=$self->{encoding} eq $_name_utf8?undef:$self->{encoding};
975 0 0         if($unicode){_encode($sql_str,$bind_param,$dst_encoding);}
  0            
976 0           $succ=$self->{dbh}->do($sql_str,undef,@$bind_param);
977 0 0         if($self->{dbh}->err){
978 0           my ($err_code,$err_detail,$die_handler)=(5,'',$self->{die_handler});
979 0 0         my $sys_err=defined($self->{dbh}->errstr)?"ErrString : ".$self->{dbh}->errstr."\n":'';
980             #==3.0.4==
981 0           $self->{err_str}=$self->{dbh}->errstr;
982 0           $self->{err_code}=$self->{dbh}->err;
983             #===end===
984 0           my $param="ParamInfo :\n"._dump([$sql_str,@$bind_param])."\n";
985 0           my $caller='';
986 0           for(my $i=0;;$i++){
987 0           my $ra_caller_info=[caller($i)];
988 0 0         if(scalar(@$ra_caller_info)==0){last;}
  0            
989             else{
990 0           $caller="\t$ra_caller_info->[1] LINE ".sprintf('%04s',$ra_caller_info->[2]).": $ra_caller_info->[3]\n$caller";
991             }
992             }
993 0           $caller="CallerInfo:\n$caller";
994 0           $err_detail="$_pkg_name\:\:$_str_func_execute\(\) throw $_str_exec_err\nHelpNote : $_str_dbh_do_err\n$sys_err$param$caller\n";
995 0 0 0       if($_DEBUG&&!$once){
996 0 0         if(defined($die_handler)){
997 0           $die_handler->execute($err_code,$err_detail,$_pkg_name);
998             }else{
999 0           CORE::die $err_detail;
1000             }
1001             }
1002 0 0         return wantarray?(undef,$err_code,$err_detail,$_pkg_name):undef;
1003             }
1004 0 0         return wantarray?($succ,0,undef,$_pkg_name):$succ;
1005             }
1006            
1007             sub select {
1008 0     0 1   my $self=shift;
1009 0           my ($sql_str,$bind_param,$inline_param)=@_;
1010 0 0 0       if(defined($bind_param)&&(ref($bind_param) eq 'ARRAY')){
    0 0        
1011             }elsif(defined($bind_param)&&(ref($bind_param) eq 'HASH')){
1012 0           $inline_param=$bind_param;
1013 0           $bind_param=[];
1014             }else{
1015 0           $bind_param=[];
1016             }
1017 0           my $succ=1;
1018            
1019 0 0 0       my $once=($_ONCE==1||$self->{once}==1)?1:0;
1020 0 0         if($once){$_ONCE=0 if $_ONCE==1;$self->{once}=0 if $self->{once}==1};
  0 0          
  0 0          
1021             #==3.0.1==
1022 0 0         $self->{err_str}=undef if defined($self->{err_str});
1023             #===end===
1024 0 0         $self->{err_code}=undef if defined($self->{err_code});
1025            
1026 0 0         if(!defined($sql_str)){
1027 0           my ($err_code,$err_detail,$die_handler)=(2,'',$self->{die_handler});
1028 0           my $sys_err='';
1029 0           my $param="ParamInfo :\n"._dump([@_])."\n";
1030 0           my $caller='';
1031 0           for(my $i=0;;$i++){
1032 0           my $ra_caller_info=[caller($i)];
1033 0 0         if(scalar(@$ra_caller_info)==0){last;}
  0            
1034             else{
1035 0           $caller="\t$ra_caller_info->[1] LINE ".sprintf('%04s',$ra_caller_info->[2]).": $ra_caller_info->[3]\n$caller";
1036             }
1037             }
1038 0           $caller="CallerInfo:\n$caller";
1039 0           $err_detail="$_pkg_name\:\:$_str_func_select\(\) throw $_str_param_err\nHelpNote : $_str_sql_null_err\n$sys_err$param$caller\n";
1040 0 0 0       if($_DEBUG&&!$once){
1041 0 0         if(defined($die_handler)){
1042 0           $die_handler->execute($err_code,$err_detail,$_pkg_name);
1043             }else{
1044 0           CORE::die $err_detail;
1045             }
1046             }
1047 0 0         return wantarray?(undef,$err_code,$err_detail,$_pkg_name):undef;
1048             }
1049            
1050 0 0         if(defined($inline_param)){
1051 0           $succ=_replace($sql_str,$inline_param);
1052             };
1053            
1054 0 0         if(!$succ){
1055 0           my($err_code,$err_detail,$die_handler)=(2,'',$self->{die_handler});
1056 0           my $sys_err='';
1057 0           my $param="ParamInfo :\n"._dump([@_])."\n";
1058 0           my $caller='';
1059 0           for(my $i=0;;$i++){
1060 0           my $ra_caller_info=[caller($i)];
1061 0 0         if(scalar(@$ra_caller_info)==0){last;}
  0            
1062             else{
1063 0           $caller="\t$ra_caller_info->[1] LINE ".sprintf('%04s',$ra_caller_info->[2]).": $ra_caller_info->[3]\n$caller";
1064             }
1065             }
1066 0           $caller="CallerInfo:\n$caller";
1067 0           $err_detail="$_pkg_name\:\:$_str_func_select\(\) throw $_str_param_err\nHelpNote : $_str_inline_null_err\n$sys_err$param$caller\n";
1068 0 0 0       if($_DEBUG&&!$once){
1069 0 0         if(defined($die_handler)){
1070 0           $die_handler->execute($err_code,$err_detail,$_pkg_name);
1071             }else{
1072 0           CORE::die $err_detail;
1073             }
1074             }
1075 0 0         return wantarray?(undef,$err_code,$err_detail,$_pkg_name):undef;
1076             }
1077            
1078 0           my $unicode=$self->{unicode};
1079 0 0         my $dst_encoding=$self->{encoding} eq $_name_utf8?undef:$self->{encoding};
1080 0 0         if($unicode){_encode($sql_str,$bind_param,$dst_encoding);}
  0            
1081            
1082 0           my $sth = $self->{dbh}->prepare($sql_str);
1083 0           $succ = $sth->execute(@$bind_param);
1084 0 0         if($sth->err){
1085 0           my ($err_code,$err_detail,$die_handler)=(5,'',$self->{die_handler});
1086 0 0         my $sys_err=defined($sth->errstr)?"ErrString : ".$sth->errstr."\n":'';
1087             #==3.0.1==
1088 0           $self->{err_str}=$sth->errstr;
1089             #===end===
1090 0           $self->{err_code}=$sth->err;
1091 0           $sth->finish();
1092 0           my $param="ParamInfo :\n"._dump([$sql_str,@$bind_param])."\n";
1093 0           my $caller='';
1094 0           for(my $i=0;;$i++){
1095 0           my $ra_caller_info=[caller($i)];
1096 0 0         if(scalar(@$ra_caller_info)==0){last;}
  0            
1097             else{
1098 0           $caller="\t$ra_caller_info->[1] LINE ".sprintf('%04s',$ra_caller_info->[2]).": $ra_caller_info->[3]\n$caller";
1099             }
1100             }
1101 0           $caller="CallerInfo:\n$caller";
1102 0           $err_detail="$_pkg_name\:\:$_str_func_select\(\) throw $_str_exec_err\nHelpNote : $_str_dbh_execute_err\n$sys_err$param$caller\n";
1103 0 0 0       if($_DEBUG&&!$once){
1104 0 0         if(defined($die_handler)){
1105 0           $die_handler->execute($err_code,$err_detail,$_pkg_name);
1106             }else{
1107 0           CORE::die $err_detail;
1108             }
1109             }
1110 0 0         return wantarray?(undef,$err_code,$err_detail,$_pkg_name):undef;
1111             }
1112            
1113 0           $succ=$sth->fetchall_arrayref({});
1114 0 0         if($sth->err){
1115 0           my ($err_code,$err_detail,$die_handler)=(5,'',$self->{die_handler});
1116 0 0         my $sys_err=defined($sth->errstr)?"ErrString : ".$sth->errstr."\n":'';
1117             #==3.0.4==
1118 0           $self->{err_str}=$self->{dbh}->errstr;
1119 0           $self->{err_code}=$self->{dbh}->err;
1120             #===end===
1121 0           $sth->finish();
1122 0           my $param="ParamInfo :\n"._dump([$sql_str,@$bind_param])."\n";
1123 0           my $caller='';
1124 0           for(my $i=0;;$i++){
1125 0           my $ra_caller_info=[caller($i)];
1126 0 0         if(scalar(@$ra_caller_info)==0){last;}
  0            
1127             else{
1128 0           $caller="\t$ra_caller_info->[1] LINE ".sprintf('%04s',$ra_caller_info->[2]).": $ra_caller_info->[3]\n$caller";
1129             }
1130             }
1131 0           $caller="CallerInfo:\n$caller";
1132 0           $err_detail="$_pkg_name\:\:$_str_func_select\(\) throw $_str_exec_err\nHelpNote : $_str_dbh_fetchall_arrayref_err\n$sys_err$param$caller\n";
1133 0 0 0       if($_DEBUG&&!$once){
1134 0 0         if(defined($die_handler)){
1135 0           $die_handler->execute($err_code,$err_detail,$_pkg_name);
1136             }else{
1137 0           CORE::die $err_detail;
1138             }
1139             }
1140 0 0         return wantarray?(undef,$err_code,$err_detail,$_pkg_name):undef;
1141             }
1142 0           $sth->finish();
1143 0 0         if($unicode){_decode($succ,$dst_encoding);};
  0            
1144 0 0         return wantarray?($succ,0,undef,$_pkg_name):$succ;
1145             }
1146            
1147            
1148             sub select_row{
1149 0     0 1   my $self=shift;
1150 0           my ($sql_str,$bind_param,$inline_param)=@_;
1151 0 0 0       if(defined($bind_param)&&(ref($bind_param) eq 'ARRAY')){
    0 0        
1152             }elsif(defined($bind_param)&&(ref($bind_param) eq 'HASH')){
1153 0           $inline_param=$bind_param;
1154 0           $bind_param=[];
1155             }else{
1156 0           $bind_param=[];
1157             }
1158 0           my $succ=1;
1159            
1160 0 0 0       my $once=($_ONCE==1||$self->{once}==1)?1:0;
1161 0 0         if($once){$_ONCE=0 if $_ONCE==1;$self->{once}=0 if $self->{once}==1};
  0 0          
  0 0          
1162             #==3.0.1==
1163 0 0         $self->{err_str}=undef if defined($self->{err_str});
1164             #===end===
1165 0 0         $self->{err_code}=undef if defined($self->{err_code});
1166            
1167 0 0         if(!defined($sql_str)){
1168 0           my ($err_code,$err_detail,$die_handler)=(2,'',$self->{die_handler});
1169 0           my $sys_err='';
1170 0           my $param="ParamInfo :\n"._dump([@_])."\n";
1171 0           my $caller='';
1172 0           for(my $i=0;;$i++){
1173 0           my $ra_caller_info=[caller($i)];
1174 0 0         if(scalar(@$ra_caller_info)==0){last;}
  0            
1175             else{
1176 0           $caller="\t$ra_caller_info->[1] LINE ".sprintf('%04s',$ra_caller_info->[2]).": $ra_caller_info->[3]\n$caller";
1177             }
1178             }
1179 0           $caller="CallerInfo:\n$caller";
1180 0           $err_detail="$_pkg_name\:\:$_str_func_select_row\(\) throw $_str_param_err\nHelpNote : $_str_sql_null_err\n$sys_err$param$caller\n";
1181 0 0 0       if($_DEBUG&&!$once){
1182 0 0         if(defined($die_handler)){
1183 0           $die_handler->execute($err_code,$err_detail,$_pkg_name);
1184             }else{
1185 0           CORE::die $err_detail;
1186             }
1187             }
1188 0 0         return wantarray?(undef,$err_code,$err_detail,$_pkg_name):undef;
1189             }
1190            
1191 0 0         if(defined($inline_param)){
1192 0           $succ=_replace($sql_str,$inline_param);
1193             };
1194            
1195 0 0         if(!$succ){
1196 0           my($err_code,$err_detail,$die_handler)=(2,'',$self->{die_handler});
1197 0           my $sys_err='';
1198 0           my $param="ParamInfo :\n"._dump([@_])."\n";
1199 0           my $caller='';
1200 0           for(my $i=0;;$i++){
1201 0           my $ra_caller_info=[caller($i)];
1202 0 0         if(scalar(@$ra_caller_info)==0){last;}
  0            
1203             else{
1204 0           $caller="\t$ra_caller_info->[1] LINE ".sprintf('%04s',$ra_caller_info->[2]).": $ra_caller_info->[3]\n$caller";
1205             }
1206             }
1207 0           $caller="CallerInfo:\n$caller";
1208 0           $err_detail="$_pkg_name\:\:$_str_func_select_row\(\) throw $_str_param_err\nHelpNote : $_str_inline_null_err\n$sys_err$param$caller\n";
1209 0 0 0       if($_DEBUG&&!$once){
1210 0 0         if(defined($die_handler)){
1211 0           $die_handler->execute($err_code,$err_detail,$_pkg_name);
1212             }else{
1213 0           CORE::die $err_detail;
1214             }
1215             }
1216 0 0         return wantarray?(undef,$err_code,$err_detail,$_pkg_name):undef;
1217             }
1218            
1219 0           my $unicode=$self->{unicode};
1220 0 0         my $dst_encoding=$self->{encoding} eq $_name_utf8?undef:$self->{encoding};
1221 0 0         if($unicode){_encode($sql_str,$bind_param,$dst_encoding);}
  0            
1222            
1223 0           my $sth = $self->{dbh}->prepare($sql_str);
1224 0           $succ = $sth->execute(@$bind_param);
1225 0 0         if($sth->err){
1226 0           my ($err_code,$err_detail,$die_handler)=(5,'',$self->{die_handler});
1227 0 0         my $sys_err=defined($sth->errstr)?"ErrString : ".$sth->errstr."\n":'';
1228             #==3.0.1==
1229 0           $self->{err_str}=$sth->errstr;
1230             #===end===
1231 0           $self->{err_code}=$sth->err;
1232 0           $sth->finish();
1233 0           my $param="ParamInfo :\n"._dump([$sql_str,@$bind_param])."\n";
1234 0           my $caller='';
1235 0           for(my $i=0;;$i++){
1236 0           my $ra_caller_info=[caller($i)];
1237 0 0         if(scalar(@$ra_caller_info)==0){last;}
  0            
1238             else{
1239 0           $caller="\t$ra_caller_info->[1] LINE ".sprintf('%04s',$ra_caller_info->[2]).": $ra_caller_info->[3]\n$caller";
1240             }
1241             }
1242 0           $caller="CallerInfo:\n$caller";
1243 0           $err_detail="$_pkg_name\:\:$_str_func_select_row\(\) throw $_str_exec_err\nHelpNote : $_str_dbh_execute_err\n$sys_err$param$caller\n";
1244 0 0 0       if($_DEBUG&&!$once){
1245 0 0         if(defined($die_handler)){
1246 0           $die_handler->execute($err_code,$err_detail,$_pkg_name);
1247             }else{
1248 0           CORE::die $err_detail;
1249             }
1250             }
1251 0 0         return wantarray?($succ,$err_code,$err_detail,$_pkg_name):$succ;
1252             }
1253            
1254 0           $succ=$sth->fetchrow_hashref();
1255 0 0         if($sth->err){
    0          
1256 0           my ($err_code,$err_detail,$die_handler)=(5,'',$self->{die_handler});
1257 0 0         my $sys_err=defined($sth->errstr)?"ErrString : ".$sth->errstr."\n":'';
1258             #==3.0.4==
1259 0           $self->{err_str}=$self->{dbh}->errstr;
1260 0           $self->{err_code}=$self->{dbh}->err;
1261             #===end===
1262 0           $sth->finish();
1263 0           my $param="ParamInfo :\n"._dump([$sql_str,@$bind_param])."\n";
1264 0           my $caller='';
1265 0           for(my $i=0;;$i++){
1266 0           my $ra_caller_info=[caller($i)];
1267 0 0         if(scalar(@$ra_caller_info)==0){last;}
  0            
1268             else{
1269 0           $caller="\t$ra_caller_info->[1] LINE ".sprintf('%04s',$ra_caller_info->[2]).": $ra_caller_info->[3]\n$caller";
1270             }
1271             }
1272 0           $caller="CallerInfo:\n$caller";
1273 0           $err_detail="$_pkg_name\:\:$_str_func_select_row\(\) throw $_str_exec_err\nHelpNote : $_str_dbh_fetchrow_hashref_err_a\n$sys_err$param$caller\n";
1274 0 0 0       if($_DEBUG&&!$once){
1275 0 0         if(defined($die_handler)){
1276 0           $die_handler->execute($err_code,$err_detail,$_pkg_name);
1277             }else{
1278 0           CORE::die $err_detail;
1279             }
1280             }
1281 0 0         return wantarray?($succ,$err_code,$err_detail,$_pkg_name):$succ;
1282             }elsif(!$succ){
1283 0           my ($err_code,$err_detail,$die_handler)=(1,'',$self->{die_handler});
1284 0           my $sys_err='';
1285 0           $sth->finish();
1286 0           my $param='';
1287 0           my $caller='';
1288 0           $err_detail="$_pkg_name\:\:$_str_func_select_row\(\) throw $_str_no_line\nHelpNote : $_str_dbh_fetchrow_hashref_err_b\n$sys_err$param$caller\n";
1289 0 0         return wantarray?($succ,$err_code,$err_detail,$_pkg_name):$succ;
1290             }
1291 0           $sth->finish();
1292 0 0         if($unicode){_decode($succ,$dst_encoding);};
  0            
1293 0 0         return wantarray?($succ,0,undef,$_pkg_name):$succ;
1294             }
1295            
1296             sub select_one{
1297 0     0 1   my $self=shift;
1298 0           my ($sql_str,$bind_param,$inline_param)=@_;
1299 0 0 0       if(defined($bind_param)&&(ref($bind_param) eq 'ARRAY')){
    0 0        
1300             }elsif(defined($bind_param)&&(ref($bind_param) eq 'HASH')){
1301 0           $inline_param=$bind_param;
1302 0           $bind_param=[];
1303             }else{
1304 0           $bind_param=[];
1305             }
1306 0           my $succ=1;
1307            
1308 0 0 0       my $once=($_ONCE==1||$self->{once}==1)?1:0;
1309 0 0         if($once){$_ONCE=0 if $_ONCE==1;$self->{once}=0 if $self->{once}==1};
  0 0          
  0 0          
1310             #==3.0.1==
1311 0 0         $self->{err_str}=undef if defined($self->{err_str});
1312             #===end===
1313 0 0         $self->{err_code}=undef if defined($self->{err_code});
1314            
1315 0 0         if(!defined($sql_str)){
1316 0           my ($err_code,$err_detail,$die_handler)=(2,'',$self->{die_handler});
1317 0           my $sys_err='';
1318 0           my $param="ParamInfo :\n"._dump([@_])."\n";
1319 0           my $caller='';
1320 0           for(my $i=0;;$i++){
1321 0           my $ra_caller_info=[caller($i)];
1322 0 0         if(scalar(@$ra_caller_info)==0){last;}
  0            
1323             else{
1324 0           $caller="\t$ra_caller_info->[1] LINE ".sprintf('%04s',$ra_caller_info->[2]).": $ra_caller_info->[3]\n$caller";
1325             }
1326             }
1327 0           $caller="CallerInfo:\n$caller";
1328 0           $err_detail="$_pkg_name\:\:$_str_func_select_one\(\) throw $_str_param_err\nHelpNote : $_str_sql_null_err\n$sys_err$param$caller\n";
1329 0 0 0       if($_DEBUG&&!$once){
1330 0 0         if(defined($die_handler)){
1331 0           $die_handler->execute($err_code,$err_detail,$_pkg_name);
1332             }else{
1333 0           CORE::die $err_detail;
1334             }
1335             }
1336             #==3.0.2==
1337             # return (undef,$err_code,$err_detail,$_pkg_name,undef);
1338 0 0         return wantarray?(undef,$err_code,$err_detail,$_pkg_name):undef;
1339             #===end===
1340             }
1341            
1342 0 0         if(defined($inline_param)){
1343 0           $succ=_replace($sql_str,$inline_param);
1344             };
1345            
1346 0 0         if(!$succ){
1347 0           my($err_code,$err_detail,$die_handler)=(2,'',$self->{die_handler});
1348 0           my $sys_err='';
1349 0           my $param="ParamInfo :\n"._dump([@_])."\n";
1350 0           my $caller='';
1351 0           for(my $i=0;;$i++){
1352 0           my $ra_caller_info=[caller($i)];
1353 0 0         if(scalar(@$ra_caller_info)==0){last;}
  0            
1354             else{
1355 0           $caller="\t$ra_caller_info->[1] LINE ".sprintf('%04s',$ra_caller_info->[2]).": $ra_caller_info->[3]\n$caller";
1356             }
1357             }
1358 0           $caller="CallerInfo:\n$caller";
1359 0           $err_detail="$_pkg_name\:\:$_str_func_select_one\(\) throw $_str_param_err\nHelpNote : $_str_inline_null_err\n$sys_err$param$caller\n";
1360 0 0 0       if($_DEBUG&&!$once){
1361 0 0         if(defined($die_handler)){
1362 0           $die_handler->execute($err_code,$err_detail,$_pkg_name);
1363             }else{
1364 0           CORE::die $err_detail;
1365             }
1366             }
1367             #==3.0.2==
1368             # return (undef,$err_code,$err_detail,$_pkg_name,undef);
1369 0 0         return wantarray?(undef,$err_code,$err_detail,$_pkg_name):undef;
1370             #===end===
1371             }
1372            
1373 0           my $unicode=$self->{unicode};
1374 0 0         my $dst_encoding=$self->{encoding} eq $_name_utf8?undef:$self->{encoding};
1375 0 0         if($unicode){_encode($sql_str,$bind_param,$dst_encoding);}
  0            
1376            
1377 0           my $sth = $self->{dbh}->prepare($sql_str);
1378 0           $succ = $sth->execute(@$bind_param);
1379 0 0         if($sth->err){
1380 0           my ($err_code,$err_detail,$die_handler)=(5,'',$self->{die_handler});
1381 0 0         my $sys_err=defined($sth->errstr)?"ErrString : ".$sth->errstr."\n":'';
1382             #==3.0.1==
1383 0           $self->{err_str}=$sth->errstr;
1384             #===end===
1385 0           $self->{err_code}=$sth->err;
1386 0           $sth->finish();
1387 0           my $param="ParamInfo :\n"._dump([$sql_str,@$bind_param])."\n";
1388 0           my $caller='';
1389 0           for(my $i=0;;$i++){
1390 0           my $ra_caller_info=[caller($i)];
1391 0 0         if(scalar(@$ra_caller_info)==0){last;}
  0            
1392             else{
1393 0           $caller="\t$ra_caller_info->[1] LINE ".sprintf('%04s',$ra_caller_info->[2]).": $ra_caller_info->[3]\n$caller";
1394             }
1395             }
1396 0           $caller="CallerInfo:\n$caller";
1397 0           $err_detail="$_pkg_name\:\:$_str_func_select_one\(\) throw $_str_exec_err\nHelpNote : $_str_dbh_execute_err\n$sys_err$param$caller\n";
1398 0 0 0       if($_DEBUG&&!$once){
1399 0 0         if(defined($die_handler)){
1400 0           $die_handler->execute($err_code,$err_detail,$_pkg_name);
1401             }else{
1402 0           CORE::die $err_detail;
1403             }
1404             }
1405             #==3.0.2==
1406             # return ($succ,$err_code,$err_detail,$_pkg_name,$succ);
1407 0 0         return wantarray?($succ,$err_code,$err_detail,$_pkg_name):$succ;
1408             #===end===
1409             }
1410            
1411 0           $succ=$sth->fetchrow_arrayref();
1412 0 0         if($sth->err){
    0          
1413 0           my ($err_code,$err_detail,$die_handler)=(5,'',$self->{die_handler});
1414 0 0         my $sys_err=defined($sth->errstr)?"ErrString : ".$sth->errstr."\n":'';
1415             #==3.0.4==
1416 0           $self->{err_str}=$self->{dbh}->errstr;
1417 0           $self->{err_code}=$self->{dbh}->err;
1418             #===end===
1419 0           $sth->finish();
1420 0           my $param="ParamInfo :\n"._dump([$sql_str,@$bind_param])."\n";
1421 0           my $caller='';
1422 0           for(my $i=0;;$i++){
1423 0           my $ra_caller_info=[caller($i)];
1424 0 0         if(scalar(@$ra_caller_info)==0){last;}
  0            
1425             else{
1426 0           $caller="\t$ra_caller_info->[1] LINE ".sprintf('%04s',$ra_caller_info->[2]).": $ra_caller_info->[3]\n$caller";
1427             }
1428             }
1429 0           $caller="CallerInfo:\n$caller";
1430 0           $err_detail="$_pkg_name\:\:$_str_func_select_one\(\) throw $_str_exec_err\nHelpNote : $_str_dbh_fetchrow_arrayref_err_a\n$sys_err$param$caller\n";
1431 0 0 0       if($_DEBUG&&!$once){
1432 0 0         if(defined($die_handler)){
1433 0           $die_handler->execute($err_code,$err_detail,$_pkg_name);
1434             }else{
1435 0           CORE::die $err_detail;
1436             }
1437             }
1438 0 0         return wantarray?($succ,$err_code,$err_detail,$_pkg_name):$succ;
1439             }elsif(!$succ){
1440 0           my ($err_code,$err_detail,$die_handler)=(1,'',$self->{die_handler});
1441 0           my $sys_err='';
1442 0           $sth->finish();
1443 0           my $param='';
1444 0           my $caller='';
1445 0           $err_detail="$_pkg_name\:\:$_str_func_select_one\(\) throw $_str_no_line\nHelpNote : $_str_dbh_fetchrow_arrayref_err_b\n$sys_err$param$caller\n";
1446 0 0         return wantarray?($succ,$err_code,$err_detail,$_pkg_name):$succ;
1447             }
1448 0           $sth->finish();
1449 0 0         if($unicode){_decode($succ->[0],$dst_encoding);};
  0            
1450 0 0         return wantarray?($succ->[0],0,undef,$_pkg_name):$succ->[0];
1451             }
1452            
1453             sub select_col{
1454 0     0 1   my $self=shift;
1455 0           my ($sql_str,$bind_param,$inline_param)=@_;
1456 0 0 0       if(defined($bind_param)&&(ref($bind_param) eq 'ARRAY')){
    0 0        
1457             }elsif(defined($bind_param)&&(ref($bind_param) eq 'HASH')){
1458 0           $inline_param=$bind_param;
1459 0           $bind_param=[];
1460             }else{
1461 0           $bind_param=[];
1462             }
1463 0           my $succ=1;
1464            
1465 0 0 0       my $once=($_ONCE==1||$self->{once}==1)?1:0;
1466 0 0         if($once){$_ONCE=0 if $_ONCE==1;$self->{once}=0 if $self->{once}==1};
  0 0          
  0 0          
1467             #==3.0.1==
1468 0 0         $self->{err_str}=undef if defined($self->{err_str});
1469             #===end===
1470 0 0         $self->{err_code}=undef if defined($self->{err_code});
1471            
1472 0 0         if(!defined($sql_str)){
1473 0           my ($err_code,$err_detail,$die_handler)=(2,'',$self->{die_handler});
1474 0           my $sys_err='';
1475 0           my $param="ParamInfo :\n"._dump([@_])."\n";
1476 0           my $caller='';
1477 0           for(my $i=0;;$i++){
1478 0           my $ra_caller_info=[caller($i)];
1479 0 0         if(scalar(@$ra_caller_info)==0){last;}
  0            
1480             else{
1481 0           $caller="\t$ra_caller_info->[1] LINE ".sprintf('%04s',$ra_caller_info->[2]).": $ra_caller_info->[3]\n$caller";
1482             }
1483             }
1484 0           $caller="CallerInfo:\n$caller";
1485 0           $err_detail="$_pkg_name\:\:$_str_func_select_col\(\) throw $_str_param_err\nHelpNote : $_str_sql_null_err\n$sys_err$param$caller\n";
1486 0 0 0       if($_DEBUG&&!$once){
1487 0 0         if(defined($die_handler)){
1488 0           $die_handler->execute($err_code,$err_detail,$_pkg_name);
1489             }else{
1490 0           CORE::die $err_detail;
1491             }
1492             }
1493 0 0         return wantarray?(undef,$err_code,$err_detail,$_pkg_name):undef;
1494             }
1495            
1496 0 0         if(defined($inline_param)){
1497 0           $succ=_replace($sql_str,$inline_param);
1498             };
1499            
1500 0 0         if(!$succ){
1501 0           my($err_code,$err_detail,$die_handler)=(2,'',$self->{die_handler});
1502 0           my $sys_err='';
1503 0           my $param="ParamInfo :\n"._dump([@_])."\n";
1504 0           my $caller='';
1505 0           for(my $i=0;;$i++){
1506 0           my $ra_caller_info=[caller($i)];
1507 0 0         if(scalar(@$ra_caller_info)==0){last;}
  0            
1508             else{
1509 0           $caller="\t$ra_caller_info->[1] LINE ".sprintf('%04s',$ra_caller_info->[2]).": $ra_caller_info->[3]\n$caller";
1510             }
1511             }
1512 0           $caller="CallerInfo:\n$caller";
1513 0           $err_detail="$_pkg_name\:\:$_str_func_select_col\(\) throw $_str_param_err\nHelpNote : $_str_inline_null_err\n$sys_err$param$caller\n";
1514 0 0 0       if($_DEBUG&&!$once){
1515 0 0         if(defined($die_handler)){
1516 0           $die_handler->execute($err_code,$err_detail,$_pkg_name);
1517             }else{
1518 0           CORE::die $err_detail;
1519             }
1520             }
1521 0 0         return wantarray?(undef,$err_code,$err_detail,$_pkg_name):undef;
1522             }
1523            
1524 0           my $unicode=$self->{unicode};
1525 0 0         my $dst_encoding=$self->{encoding} eq $_name_utf8?undef:$self->{encoding};
1526 0 0         if($unicode){_encode($sql_str,$bind_param,$dst_encoding);}
  0            
1527            
1528 0           my $sth = $self->{dbh}->prepare($sql_str);
1529 0           $succ = $sth->execute(@$bind_param);
1530 0 0         if(!$succ){
1531 0           my ($err_code,$err_detail,$die_handler)=(5,'',$self->{die_handler});
1532 0 0         my $sys_err=defined($sth->errstr)?"ErrString : ".$sth->errstr."\n":'';
1533             #==3.0.1==
1534 0           $self->{err_str}=$sth->errstr;
1535             #===end===
1536 0           $self->{err_code}=$sth->err;
1537 0           $sth->finish();
1538 0           my $param="ParamInfo :\n"._dump([$sql_str,@$bind_param])."\n";
1539 0           my $caller='';
1540 0           for(my $i=0;;$i++){
1541 0           my $ra_caller_info=[caller($i)];
1542 0 0         if(scalar(@$ra_caller_info)==0){last;}
  0            
1543             else{
1544 0           $caller="\t$ra_caller_info->[1] LINE ".sprintf('%04s',$ra_caller_info->[2]).": $ra_caller_info->[3]\n$caller";
1545             }
1546             }
1547 0           $caller="CallerInfo:\n$caller";
1548 0           $err_detail="$_pkg_name\:\:$_str_func_select_col\(\) throw $_str_exec_err\nHelpNote : $_str_dbh_execute_err\n$sys_err$param$caller\n";
1549 0 0 0       if($_DEBUG&&!$once){
1550 0 0         if(defined($die_handler)){
1551 0           $die_handler->execute($err_code,$err_detail,$_pkg_name);
1552             }else{
1553 0           CORE::die $err_detail;
1554             }
1555             }
1556 0 0         return wantarray?($succ,$err_code,$err_detail,$_pkg_name):$succ;
1557             }
1558            
1559 0           $succ=$sth->fetchall_arrayref([0]);
1560 0 0         if($sth->err){
1561 0           my ($err_code,$err_detail,$die_handler)=(5,'',$self->{die_handler});
1562 0 0         my $sys_err=defined($sth->errstr)?"ErrString : ".$sth->errstr."\n":'';
1563             #==3.0.4==
1564 0           $self->{err_str}=$self->{dbh}->errstr;
1565 0           $self->{err_code}=$self->{dbh}->err;
1566             #===end===
1567 0           $sth->finish();
1568 0           my $param="ParamInfo :\n"._dump([$sql_str,@$bind_param])."\n";
1569 0           my $caller='';
1570 0           for(my $i=0;;$i++){
1571 0           my $ra_caller_info=[caller($i)];
1572 0 0         if(scalar(@$ra_caller_info)==0){last;}
  0            
1573             else{
1574 0           $caller="\t$ra_caller_info->[1] LINE ".sprintf('%04s',$ra_caller_info->[2]).": $ra_caller_info->[3]\n$caller";
1575             }
1576             }
1577 0           $caller="CallerInfo:\n$caller";
1578 0           $err_detail="$_pkg_name\:\:$_str_func_select_col\(\) throw $_str_exec_err\nHelpNote : $_str_dbh_fetchall_arrayref_err\n$sys_err$param$caller\n";
1579 0 0 0       if($_DEBUG&&!$once){
1580 0 0         if(defined($die_handler)){
1581 0           $die_handler->execute($err_code,$err_detail,$_pkg_name);
1582             }else{
1583 0           CORE::die $err_detail;
1584             }
1585             }
1586 0 0         return wantarray?(undef,$err_code,$err_detail,$_pkg_name):undef;
1587             }
1588 0           $sth->finish();
1589 0           for(my $i=scalar(@$succ);$i-->0;){
1590 0           $succ->[$i]=$succ->[$i]->[0];
1591             }
1592 0 0         if($unicode){_decode($succ,$dst_encoding);};
  0            
1593 0 0         return wantarray?($succ,0,undef,$_pkg_name):$succ;
1594             }
1595            
1596             sub select_array{
1597 0     0 1   my $self=shift;
1598 0           my ($sql_str,$bind_param,$inline_param)=@_;
1599 0 0 0       if(defined($bind_param)&&(ref($bind_param) eq 'ARRAY')){
    0 0        
1600             }elsif(defined($bind_param)&&(ref($bind_param) eq 'HASH')){
1601 0           $inline_param=$bind_param;
1602 0           $bind_param=[];
1603             }else{
1604 0           $bind_param=[];
1605             }
1606 0           my $succ=1;
1607            
1608 0 0 0       my $once=($_ONCE==1||$self->{once}==1)?1:0;
1609 0 0         if($once){$_ONCE=0 if $_ONCE==1;$self->{once}=0 if $self->{once}==1};
  0 0          
  0 0          
1610             #==3.0.1==
1611 0 0         $self->{err_str}=undef if defined($self->{err_str});
1612             #===end===
1613 0 0         $self->{err_code}=undef if defined($self->{err_code});
1614            
1615 0 0         if(!defined($sql_str)){
1616 0           my ($err_code,$err_detail,$die_handler)=(2,'',$self->{die_handler});
1617 0           my $sys_err='';
1618 0           my $param="ParamInfo :\n"._dump([@_])."\n";
1619 0           my $caller='';
1620 0           for(my $i=0;;$i++){
1621 0           my $ra_caller_info=[caller($i)];
1622 0 0         if(scalar(@$ra_caller_info)==0){last;}
  0            
1623             else{
1624 0           $caller="\t$ra_caller_info->[1] LINE ".sprintf('%04s',$ra_caller_info->[2]).": $ra_caller_info->[3]\n$caller";
1625             }
1626             }
1627 0           $caller="CallerInfo:\n$caller";
1628 0           $err_detail="$_pkg_name\:\:$_str_func_select_array\(\) throw $_str_param_err\nHelpNote : $_str_sql_null_err\n$sys_err$param$caller\n";
1629 0 0 0       if($_DEBUG&&!$once){
1630 0 0         if(defined($die_handler)){
1631 0           $die_handler->execute($err_code,$err_detail,$_pkg_name);
1632             }else{
1633 0           CORE::die $err_detail;
1634             }
1635             }
1636 0 0         return wantarray?(undef,$err_code,$err_detail,$_pkg_name):undef;
1637             }
1638            
1639 0 0         if(defined($inline_param)){
1640 0           $succ=_replace($sql_str,$inline_param);
1641             };
1642            
1643 0 0         if(!$succ){
1644 0           my($err_code,$err_detail,$die_handler)=(2,'',$self->{die_handler});
1645 0           my $sys_err='';
1646 0           my $param="ParamInfo :\n"._dump([@_])."\n";
1647 0           my $caller='';
1648 0           for(my $i=0;;$i++){
1649 0           my $ra_caller_info=[caller($i)];
1650 0 0         if(scalar(@$ra_caller_info)==0){last;}
  0            
1651             else{
1652 0           $caller="\t$ra_caller_info->[1] LINE ".sprintf('%04s',$ra_caller_info->[2]).": $ra_caller_info->[3]\n$caller";
1653             }
1654             }
1655 0           $caller="CallerInfo:\n$caller";
1656 0           $err_detail="$_pkg_name\:\:$_str_func_select_array\(\) throw $_str_param_err\nHelpNote : $_str_inline_null_err\n$sys_err$param$caller\n";
1657 0 0 0       if($_DEBUG&&!$once){
1658 0 0         if(defined($die_handler)){
1659 0           $die_handler->execute($err_code,$err_detail,$_pkg_name);
1660             }else{
1661 0           CORE::die $err_detail;
1662             }
1663             }
1664 0 0         return wantarray?(undef,$err_code,$err_detail,$_pkg_name):undef;
1665             }
1666            
1667 0           my $unicode=$self->{unicode};
1668 0 0         my $dst_encoding=$self->{encoding} eq $_name_utf8?undef:$self->{encoding};
1669 0 0         if($unicode){_encode($sql_str,$bind_param,$dst_encoding);}
  0            
1670            
1671 0           my $sth = $self->{dbh}->prepare($sql_str);
1672 0           $succ = $sth->execute(@$bind_param);
1673 0 0         if($sth->err){
1674 0           my ($err_code,$err_detail,$die_handler)=(5,'',$self->{die_handler});
1675 0 0         my $sys_err=defined($sth->errstr)?"ErrString : ".$sth->errstr."\n":'';
1676             #==3.0.1==
1677 0           $self->{err_str}=$sth->errstr;
1678             #===end===
1679 0           $self->{err_code}=$sth->err;
1680 0           $sth->finish();
1681 0           my $param="ParamInfo :\n"._dump([$sql_str,@$bind_param])."\n";
1682 0           my $caller='';
1683 0           for(my $i=0;;$i++){
1684 0           my $ra_caller_info=[caller($i)];
1685 0 0         if(scalar(@$ra_caller_info)==0){last;}
  0            
1686             else{
1687 0           $caller="\t$ra_caller_info->[1] LINE ".sprintf('%04s',$ra_caller_info->[2]).": $ra_caller_info->[3]\n$caller";
1688             }
1689             }
1690 0           $caller="CallerInfo:\n$caller";
1691 0           $err_detail="$_pkg_name\:\:$_str_func_select_array\(\) throw $_str_exec_err\nHelpNote : $_str_dbh_execute_err\n$sys_err$param$caller\n";
1692 0 0 0       if($_DEBUG&&!$once){
1693 0 0         if(defined($die_handler)){
1694 0           $die_handler->execute($err_code,$err_detail,$_pkg_name);
1695             }else{
1696 0           CORE::die $err_detail;
1697             }
1698             }
1699 0 0         return wantarray?(undef,$err_code,$err_detail,$_pkg_name):undef;
1700             }
1701            
1702 0           $succ=$sth->fetchall_arrayref();
1703 0 0         if($sth->err){
1704 0           my ($err_code,$err_detail,$die_handler)=(5,'',$self->{die_handler});
1705 0 0         my $sys_err=defined($sth->errstr)?"ErrString : ".$sth->errstr."\n":'';
1706             #==3.0.4==
1707 0           $self->{err_str}=$self->{dbh}->errstr;
1708 0           $self->{err_code}=$self->{dbh}->err;
1709             #===end===
1710 0           $sth->finish();
1711 0           my $param="ParamInfo :\n"._dump([$sql_str,@$bind_param])."\n";
1712 0           my $caller='';
1713 0           for(my $i=0;;$i++){
1714 0           my $ra_caller_info=[caller($i)];
1715 0 0         if(scalar(@$ra_caller_info)==0){last;}
  0            
1716             else{
1717 0           $caller="\t$ra_caller_info->[1] LINE ".sprintf('%04s',$ra_caller_info->[2]).": $ra_caller_info->[3]\n$caller";
1718             }
1719             }
1720 0           $caller="CallerInfo:\n$caller";
1721 0           $err_detail="$_pkg_name\:\:$_str_func_select_array\(\) throw $_str_exec_err\nHelpNote : $_str_dbh_fetchall_arrayref_err\n$sys_err$param$caller\n";
1722 0 0 0       if($_DEBUG&&!$once){
1723 0 0         if(defined($die_handler)){
1724 0           $die_handler->execute($err_code,$err_detail,$_pkg_name);
1725             }else{
1726 0           CORE::die $err_detail;
1727             }
1728             }
1729 0 0         return wantarray?(undef,$err_code,$err_detail,$_pkg_name):undef;
1730             }
1731 0           $sth->finish();
1732 0 0         if($unicode){_decode($succ,$dst_encoding);};
  0            
1733 0 0         return wantarray?($succ,0,undef,$_pkg_name):$succ;
1734             }
1735            
1736             #==3.0.9==
1737             sub DEFAULT{
1738 0     0 0   my $code=1;
1739 0 0         if(scalar(@_)==0){
    0          
1740 0           return bless [$code,'DEFAULT'],'EasyDBAccess::CONSTANT';
1741             }elsif(scalar(@_)==1){
1742 0 0 0       return ref $_[0] eq 'EasyDBAccess::CONSTANT' && $_[0]->[0]==$code?1:'';
1743             }else{
1744 0           die 'EasyDBAccess::DEFAULT: param number should be 0 or 1';
1745             }
1746             }
1747             #===end===
1748            
1749             1;
1750            
1751            
1752             package _EasyDBAccess_EasyHandler;
1753            
1754             our $_pkg_name=__PACKAGE__;
1755 0     0     sub foo{1};
1756            
1757             our $_type_value=1;
1758             our $_type_sub=2;
1759            
1760             sub new{
1761 0     0     my $param_count=scalar(@_);
1762 0           my $self = bless {},$_pkg_name;
1763 0 0         if($param_count==1){
    0          
    0          
1764 0           $self->{'type'}=$_type_value;
1765 0           $self->{'value'}='';
1766             }elsif($param_count==2){
1767 0           my ($class,$value)=@_;
1768 0           $self->{'type'}=$_type_value;
1769 0           $self->{'value'}=$value;
1770             }elsif($param_count==3){
1771 0           my($class,$sub,$param)=@_;
1772 0           $self->{'type'}=$_type_sub;
1773 0           $self->{'sub'}=$sub;
1774 0           $self->{'param'}=[@$param];
1775             }else{
1776 0           CORE::die $_pkg_name.'::new: param not fit';
1777             }
1778 0           return $self;
1779             }
1780            
1781             sub execute{
1782 0     0     my $self=shift;
1783 0 0         if($self->{'type'}==$_type_value){
    0          
1784 0           return $self->{'value'};
1785             }elsif($self->{'type'}==$_type_sub){
1786 0           return $self->{'sub'}->(@{$self->{'param'}},@_);
  0            
1787             }else{
1788 0           CORE::die $_pkg_name.'::execute: not a valid type;';
1789             }
1790             }
1791            
1792             1;
1793            
1794             __END__