/
DBCubrid.class.php
1183 lines (1037 loc) · 26.4 KB
/
DBCubrid.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/**
* - DB child class
* - Cubrid DBMS to use the class
* - Works with CUBRID up to 8.4.1
*
* @author NAVER (developers@xpressengine.com)
* @package /classes/db
* @version 0.1
*/
class DBCubrid extends DB
{
/**
* prefix of XE tables(One more XE can be installed on a single DB)
* @var string
*/
var $prefix = 'xe_';
/**
* max size of constant in CUBRID(if string is larger than this, '...'+'...' should be used)
* @var int
*/
var $cutlen = 12000;
var $comment_syntax = '/* %s */';
/**
* column type used in CUBRID
*
* column_type should be replaced for each DBMS's type
* becasue it uses commonly defined type in the schema/query xml
* @var array
*/
var $column_type = array(
'bignumber' => 'numeric(20)',
'number' => 'integer',
'varchar' => 'character varying',
'char' => 'character',
'tinytext' => 'character varying(256)',
'text' => 'character varying(1073741823)',
'bigtext' => 'character varying(1073741823)',
'date' => 'character varying(14)',
'float' => 'float',
);
/**
* constructor
* @return void
*/
function DBCubrid($auto_connect = TRUE)
{
$this->_setDBInfo();
if($auto_connect) $this->_connect();
}
/**
* Create an instance of this class
* @return DBCubrid return DBCubrid object instance
*/
function create()
{
return new DBCubrid;
}
/**
* DB Connect
* this method is private
* @param array $connection connection's value is db_hostname, db_port, db_database, db_userid, db_password
* @return resource
*/
function __connect($connection)
{
// attempts to connect
$result = @cubrid_connect($connection["db_hostname"], $connection["db_port"], $connection["db_database"], $connection["db_userid"], $connection["db_password"]);
// check connections
if(!$result)
{
$this->setError(-1, 'database connect fail');
return;
}
if(!defined('__CUBRID_VERSION__'))
{
$cubrid_version = cubrid_get_server_info($result);
$cubrid_version_elem = explode('.', $cubrid_version);
$cubrid_version = $cubrid_version_elem[0] . '.' . $cubrid_version_elem[1] . '.' . $cubrid_version_elem[2];
define('__CUBRID_VERSION__', $cubrid_version);
}
if(__CUBRID_VERSION__ >= '8.4.0')
cubrid_set_autocommit($result, CUBRID_AUTOCOMMIT_TRUE);
return $result;
}
/**
* DB disconnection
* this method is private
* @param resource $connection
* @return void
*/
function _close($connection)
{
@cubrid_commit($connection);
@cubrid_disconnect($connection);
$this->transaction_started = FALSE;
}
/**
* Handles quatation of the string variables from the query
* @param string $string
* @return string
*/
function addQuotes($string)
{
if(version_compare(PHP_VERSION, "5.4.0", "<") &&
get_magic_quotes_gpc())
{
$string = stripslashes(str_replace("\\", "\\\\", $string));
}
if(!is_numeric($string))
{
/*
if ($this->isConnected()) {
$string = cubrid_real_escape_string($string);
}
else {
$string = str_replace("'","\'",$string);
}
*/
$string = str_replace("'", "''", $string);
}
return $string;
}
/**
* DB transaction start
* this method is private
* @return boolean
*/
function _begin($transactionLevel = 0)
{
if(__CUBRID_VERSION__ >= '8.4.0')
{
$connection = $this->_getConnection('master');
if(!$transactionLevel)
{
cubrid_set_autocommit($connection, CUBRID_AUTOCOMMIT_FALSE);
}
else
{
$this->_query("SAVEPOINT SP" . $transactionLevel, $connection);
}
}
return TRUE;
}
/**
* DB transaction rollback
* this method is private
* @return boolean
*/
function _rollback($transactionLevel = 0)
{
$connection = $this->_getConnection('master');
$point = $transactionLevel - 1;
if($point)
{
$this->_query("ROLLBACK TO SP" . $point, $connection);
}
else
{
@cubrid_rollback($connection);
}
return TRUE;
}
/**
* DB transaction commit
* this method is private
* @return boolean
*/
function _commit()
{
$connection = $this->_getConnection('master');
@cubrid_commit($connection);
return TRUE;
}
/**
* Execute the query
* this method is private
* @param string $query
* @param resource $connection
* @return resource
*/
function __query($query, $connection)
{
if($this->use_prepared_statements == 'Y')
{
$req = @cubrid_prepare($connection, $query);
if(!$req)
{
$this->_setError();
return false;
}
$position = 0;
if($this->param)
{
foreach($this->param as $param)
{
$value = $param->getUnescapedValue();
$type = $param->getType();
if($param->isColumnName())
{
continue;
}
switch($type)
{
case 'number' :
$bind_type = 'numeric';
break;
case 'varchar' :
$bind_type = 'string';
break;
default:
$bind_type = 'string';
}
if(is_array($value))
{
foreach($value as $v)
{
$bound = @cubrid_bind($req, ++$position, $v, $bind_type);
if(!$bound)
{
$this->_setError();
return false;
}
}
}
else
{
$bound = @cubrid_bind($req, ++$position, $value, $bind_type);
if(!$bound)
{
$this->_setError();
return false;
}
}
}
}
$result = @cubrid_execute($req);
if(!$result)
{
$this->_setError();
return false;
}
return $req;
}
// Execute the query
$result = @cubrid_execute($connection, $query);
// error check
if(!$result)
{
$this->_setError();
return false;
}
// Return the result
return $result;
}
/**
* Retrieve CUBRID error and set to object
*
* @author Corina Udrescu (dev@xpressengine.org)
*/
function _setError()
{
$code = cubrid_error_code();
$msg = cubrid_error_msg();
$this->setError($code, $msg);
}
/**
* Fetch the result
* @param resource $result
* @param int|NULL $arrayIndexEndValue
* @return array
*/
function _fetch($result, $arrayIndexEndValue = NULL)
{
$output = array();
if(!$this->isConnected() || $this->isError() || !$result)
{
return array();
}
if($this->use_prepared_statements == 'Y')
{
}
// TODO Improve this piece of code
// This code trims values from char type columns
$col_types = cubrid_column_types($result);
$col_names = cubrid_column_names($result);
$max = count($col_types);
for($count = 0; $count < $max; $count++)
{
if(preg_match("/^char/", $col_types[$count]) > 0)
{
$char_type_fields[] = $col_names[$count];
}
}
while($tmp = cubrid_fetch($result, CUBRID_OBJECT))
{
if(is_array($char_type_fields))
{
foreach($char_type_fields as $val)
{
$tmp->{$val} = rtrim($tmp->{$val});
}
}
if($arrayIndexEndValue)
{
$output[$arrayIndexEndValue--] = $tmp;
}
else
{
$output[] = $tmp;
}
}
unset($char_type_fields);
if($result)
{
cubrid_close_request($result);
}
if(count($output) == 1)
{
// If call is made for pagination, always return array
if(isset($arrayIndexEndValue))
{
return $output;
}
// Else return object instead of array
else
{
return $output[0];
}
}
return $output;
}
/**
* Return the sequence value incremented by 1
* Auto_increment column only used in the CUBRID sequence table
* @return int
*/
function getNextSequence()
{
$this->_makeSequence();
$query = sprintf("select \"%ssequence\".\"nextval\" as \"seq\" from db_root", $this->prefix);
$result = $this->_query($query);
$output = $this->_fetch($result);
return $output->seq;
}
/**
* if the table already exists, set the status to GLOBALS
* @return void
*/
function _makeSequence()
{
if($_GLOBALS['XE_EXISTS_SEQUENCE'])
return;
// check cubrid serial
$query = sprintf('select count(*) as "count" from "db_serial" where name=\'%ssequence\'', $this->prefix);
$result = $this->_query($query);
$output = $this->_fetch($result);
// if do not create serial
if($output->count == 0)
{
$query = sprintf('select max("a"."srl") as "srl" from ' .
'( select max("document_srl") as "srl" from ' .
'"%sdocuments" UNION ' .
'select max("comment_srl") as "srl" from ' .
'"%scomments" UNION ' .
'select max("member_srl") as "srl" from ' .
'"%smember"' .
') as "a"', $this->prefix, $this->prefix, $this->prefix);
$result = $this->_query($query);
$output = $this->_fetch($result);
$srl = $output->srl;
if($srl < 1)
{
$start = 1;
}
else
{
$start = $srl + 1000000;
}
// create sequence
$query = sprintf('create serial "%ssequence" start with %s increment by 1 minvalue 1 maxvalue 10000000000000000000000000000000000000 nocycle;', $this->prefix, $start);
$this->_query($query);
}
$_GLOBALS['XE_EXISTS_SEQUENCE'] = TRUE;
}
/**
* Check a table exists status
* @param string $target_name
* @return boolean
*/
function isTableExists($target_name)
{
if($target_name == 'sequence')
{
$query = sprintf("select \"name\" from \"db_serial\" where \"name\" = '%s%s'", $this->prefix, $target_name);
}
else
{
$query = sprintf("select \"class_name\" from \"db_class\" where \"class_name\" = '%s%s'", $this->prefix, $target_name);
}
$result = $this->_query($query);
if(cubrid_num_rows($result) > 0)
{
$output = TRUE;
}
else
{
$output = FALSE;
}
if($result)
{
cubrid_close_request($result);
}
return $output;
}
/**
* Add a column to the table
* @param string $table_name table name
* @param string $column_name column name
* @param string $type column type, default value is 'number'
* @param int $size column size
* @param string|int $default default value
* @param boolean $notnull not null status, default value is false
* @return void
*/
function addColumn($table_name, $column_name, $type = 'number', $size = '', $default = null, $notnull = FALSE)
{
$type = strtoupper($this->column_type[$type]);
if($type == 'INTEGER')
{
$size = '';
}
$query = sprintf("alter class \"%s%s\" add \"%s\" ", $this->prefix, $table_name, $column_name);
if($type == 'char' || $type == 'varchar')
{
if($size)
{
$size = $size * 3;
}
}
if($size)
{
$query .= sprintf("%s(%s) ", $type, $size);
}
else
{
$query .= sprintf("%s ", $type);
}
if(isset($default))
{
if($type == 'INTEGER' || $type == 'BIGINT' || $type == 'INT')
{
$query .= sprintf("default %d ", $default);
}
else
{
$query .= sprintf("default '%s' ", $default);
}
}
if($notnull)
{
$query .= "not null ";
}
return $this->_query($query);
}
/**
* Drop a column from the table
* @param string $table_name table name
* @param string $column_name column name
* @return void
*/
function dropColumn($table_name, $column_name)
{
$query = sprintf("alter class \"%s%s\" drop \"%s\" ", $this->prefix, $table_name, $column_name);
$this->_query($query);
}
/**
* Check column exist status of the table
* @param string $table_name table name
* @param string $column_name column name
* @return boolean
*/
function isColumnExists($table_name, $column_name)
{
$query = sprintf("select \"attr_name\" from \"db_attribute\" where " . "\"attr_name\" ='%s' and \"class_name\" = '%s%s'", $column_name, $this->prefix, $table_name);
$result = $this->_query($query);
if(cubrid_num_rows($result) > 0)
{
$output = TRUE;
}
else
{
$output = FALSE;
}
if($result)
{
cubrid_close_request($result);
}
return $output;
}
/**
* Add an index to the table
* $target_columns = array(col1, col2)
* $is_unique? unique : none
* @param string $table_name table name
* @param string $index_name index name
* @param string|array $target_columns target column or columns
* @param boolean $is_unique
* @return void
*/
function addIndex($table_name, $index_name, $target_columns, $is_unique = FALSE)
{
if(!is_array($target_columns))
{
$target_columns = array($target_columns);
}
$query = sprintf("create %s index \"%s\" on \"%s%s\" (%s);", $is_unique ? 'unique' : '', $index_name, $this->prefix, $table_name, '"' . implode('","', $target_columns) . '"');
$this->_query($query);
}
/**
* Drop an index from the table
* @param string $table_name table name
* @param string $index_name index name
* @param boolean $is_unique
* @return void
*/
function dropIndex($table_name, $index_name, $is_unique = FALSE)
{
$query = sprintf("drop %s index \"%s\" on \"%s%s\"", $is_unique ? 'unique' : '', $index_name, $this->prefix, $table_name);
$this->_query($query);
}
/**
* Check index status of the table
* @param string $table_name table name
* @param string $index_name index name
* @return boolean
*/
function isIndexExists($table_name, $index_name)
{
$query = sprintf("select \"index_name\" from \"db_index\" where " . "\"class_name\" = '%s%s' and (\"index_name\" = '%s' or \"index_name\" = '%s') ", $this->prefix, $table_name, $this->prefix . $index_name, $index_name);
$result = $this->_query($query);
if($this->isError())
{
return FALSE;
}
$output = $this->_fetch($result);
if(!$output)
{
return FALSE;
}
return TRUE;
}
/**
* Delete duplicated index of the table
* @return boolean
*/
function deleteDuplicateIndexes()
{
$query = sprintf("
select \"class_name\"
, case
when substr(\"index_name\", 0, %d) = '%s'
then substr(\"index_name\", %d)
else \"index_name\" end as unprefixed_index_name
, \"is_unique\"
from \"db_index\"
where \"class_name\" like %s
group by \"class_name\"
, case
when substr(\"index_name\", 0, %d) = '%s'
then substr(\"index_name\", %d)
else \"index_name\"
end
having count(*) > 1
", strlen($this->prefix)
, $this->prefix
, strlen($this->prefix) + 1
, "'" . $this->prefix . '%' . "'"
, strlen($this->prefix)
, $this->prefix
, strlen($this->prefix) + 1
);
$result = $this->_query($query);
if($this->isError())
{
return FALSE;
}
$output = $this->_fetch($result);
if(!$output)
{
return FALSE;
}
if(!is_array($output))
{
$indexes_to_be_deleted = array($output);
}
else
{
$indexes_to_be_deleted = $output;
}
foreach($indexes_to_be_deleted as $index)
{
$this->dropIndex(substr($index->class_name, strlen($this->prefix))
, $this->prefix . $index->unprefixed_index_name
, $index->is_unique == 'YES' ? TRUE : FALSE);
}
return TRUE;
}
/**
* Creates a table by using xml contents
* @param string $xml_doc xml schema contents
* @return void|object
*/
function createTableByXml($xml_doc)
{
return $this->_createTable($xml_doc);
}
/**
* Creates a table by using xml file path
* @param string $file_name xml schema file path
* @return void|object
*/
function createTableByXmlFile($file_name)
{
if(!file_exists($file_name))
{
return;
}
// read xml file
$buff = FileHandler::readFile($file_name);
return $this->_createTable($buff);
}
/**
* Create table by using the schema xml
*
* type : number, varchar, tinytext, text, bigtext, char, date, \n
* opt : notnull, default, size\n
* index : primary key, index, unique\n
* @param string $xml_doc xml schema contents
* @return void|object
*/
function _createTable($xml_doc)
{
// xml parsing
$oXml = new XmlParser();
$xml_obj = $oXml->parse($xml_doc);
// Create a table schema
$table_name = $xml_obj->table->attrs->name;
// if the table already exists exit function
if($this->isTableExists($table_name))
{
return;
}
// If the table name is sequence, it creates a serial
if($table_name == 'sequence')
{
$query = sprintf('create serial "%s" start with 1 increment by 1' .
' minvalue 1 ' .
'maxvalue 10000000000000000000000000000000000000' . ' nocycle;', $this->prefix . $table_name);
return $this->_query($query);
}
$table_name = $this->prefix . $table_name;
$query = sprintf('create class "%s";', $table_name);
$this->_query($query);
if(!is_array($xml_obj->table->column))
{
$columns[] = $xml_obj->table->column;
}
else
{
$columns = $xml_obj->table->column;
}
$query = sprintf("alter class \"%s\" add attribute ", $table_name);
$primary_list = array();
$unique_list = array();
$index_list = array();
foreach($columns as $column)
{
$name = $column->attrs->name;
$type = $column->attrs->type;
$size = $column->attrs->size;
$notnull = $column->attrs->notnull;
$primary_key = $column->attrs->primary_key;
$index = $column->attrs->index;
$unique = $column->attrs->unique;
$default = $column->attrs->default;
switch($this->column_type[$type])
{
case 'integer' :
$size = NULL;
break;
case 'text' :
$size = NULL;
break;
}
if(isset($default) && ($type == 'varchar' || $type == 'char' ||
$type == 'text' || $type == 'tinytext' || $type == 'bigtext'))
{
$default = sprintf("'%s'", $default);
}
if($type == 'varchar' || $type == 'char')
{
if($size)
$size = $size * 3;
}
$column_schema[] = sprintf('"%s" %s%s %s %s', $name, $this->column_type[$type], $size ? '(' . $size . ')' : '', isset($default) ? "default " . $default : '', $notnull ? 'not null' : '');
if($primary_key)
{
$primary_list[] = $name;
}
else if($unique)
{
$unique_list[$unique][] = $name;
}
else if($index)
{
$index_list[$index][] = $name;
}
}
$query .= implode(',', $column_schema) . ';';
$this->_query($query);
if(count($primary_list))
{
$query = sprintf("alter class \"%s\" add attribute constraint " . "\"pkey_%s\" PRIMARY KEY(%s);", $table_name, $table_name, '"' . implode('","', $primary_list) . '"');
$this->_query($query);
}
if(count($unique_list))
{
foreach($unique_list as $key => $val)
{
$query = sprintf("create unique index \"%s\" on \"%s\" " . "(%s);", $key, $table_name, '"' . implode('","', $val) . '"');
$this->_query($query);
}
}
if(count($index_list))
{
foreach($index_list as $key => $val)
{
$query = sprintf("create index \"%s\" on \"%s\" (%s);", $key, $table_name, '"' . implode('","', $val) . '"');
$this->_query($query);
}
}
}
/**
* Handles insertAct
* @param BaseObject $queryObject
* @param boolean $with_values
* @return resource
*/
function _executeInsertAct($queryObject, $with_values = TRUE)
{
if($this->use_prepared_statements == 'Y')
{
$this->param = $queryObject->getArguments();
$with_values = FALSE;
}
$query = $this->getInsertSql($queryObject, $with_values);
if(is_a($query, 'BaseObject'))
{
unset($this->param);
return;
}
$query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
$result = $this->_query($query);
if($result && !$this->transaction_started)
{
$this->_commit();
}
unset($this->param);
return $result;
}
/**
* Handles updateAct
* @param BaseObject $queryObject
* @param boolean $with_values
* @return resource
*/
function _executeUpdateAct($queryObject, $with_values = TRUE)
{
if($this->use_prepared_statements == 'Y')
{
$this->param = $queryObject->getArguments();
$with_values = FALSE;
}
$query = $this->getUpdateSql($queryObject, $with_values);
if(is_a($query, 'BaseObject'))
{
unset($this->param);
return;
}
$query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
$result = $this->_query($query);
if($result && !$this->transaction_started)
{
$this->_commit();
}
unset($this->param);
return $result;
}
/**
* Handles deleteAct
* @param BaseObject $queryObject
* @param boolean $with_values
* @return resource
*/
function _executeDeleteAct($queryObject, $with_values = TRUE)
{
if($this->use_prepared_statements == 'Y')
{
$this->param = $queryObject->getArguments();
$with_values = FALSE;
}
$query = $this->getDeleteSql($queryObject, $with_values);
if(is_a($query, 'BaseObject'))
{
unset($this->param);
return;
}
$query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
$result = $this->_query($query);
if($result && !$this->transaction_started)
{
$this->_commit();
}
unset($this->param);
return $result;
}
/**
* Handle selectAct
* To get a specific page list easily in select statement,
* a method, navigation, is used
* @param BaseObject $queryObject
* @param resource $connection
* @param boolean $with_values
* @return BaseObject
*/
function _executeSelectAct($queryObject, $connection = NULL, $with_values = TRUE)
{
if($this->use_prepared_statements == 'Y')
{
$this->param = $queryObject->getArguments();
$with_values = FALSE;
}
$limit = $queryObject->getLimit();
if($limit && $limit->isPageHandler())
{
return $this->queryPageLimit($queryObject, $connection, $with_values);
}
else
{
$query = $this->getSelectSql($queryObject, $with_values);
if(is_a($query, 'BaseObject'))
{
unset($this->param);
return;
}
$query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
$result = $this->_query($query, $connection);
if($this->isError())
{
unset($this->param);
return $this->queryError($queryObject);
}
$data = $this->_fetch($result);
$buff = new BaseObject();
$buff->data = $data;
unset($this->param);
return $buff;
}
}
/**
* If have a error, return error object
* @param BaseObject $queryObject
* @return BaseObject
*/
function queryError($queryObject)