@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | function __construct($auto_connect = TRUE) |
46 | 46 | { |
47 | 47 | $this->_setDBInfo(); |
48 | - if($auto_connect) $this->_connect(); |
|
48 | + if ($auto_connect) $this->_connect(); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | //sqlsrv_configure( 'LogSubsystems', SQLSRV_LOG_SYSTEM_ALL ); |
71 | 71 | $result = @sqlsrv_connect($connection["db_hostname"], array('Database' => $connection["db_database"], 'UID' => $connection["db_userid"], 'PWD' => $connection["db_password"])); |
72 | 72 | |
73 | - if(!$result) |
|
73 | + if (!$result) |
|
74 | 74 | { |
75 | 75 | $errors = print_r(sqlsrv_errors(), true); |
76 | - $this->setError(-1, 'database connect fail' . PHP_EOL . $errors); |
|
76 | + $this->setError(-1, 'database connect fail'.PHP_EOL.$errors); |
|
77 | 77 | return; |
78 | 78 | } |
79 | 79 | return $result; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | function addQuotes($string) |
101 | 101 | { |
102 | - if(version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc()) |
|
102 | + if (version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc()) |
|
103 | 103 | { |
104 | 104 | $string = stripslashes(str_replace("\\", "\\\\", $string)); |
105 | 105 | } |
@@ -117,16 +117,16 @@ discard block |
||
117 | 117 | { |
118 | 118 | $connection = $this->_getConnection('master'); |
119 | 119 | |
120 | - if(!$transactionLevel) |
|
120 | + if (!$transactionLevel) |
|
121 | 121 | { |
122 | - if(sqlsrv_begin_transaction($connection) === false) |
|
122 | + if (sqlsrv_begin_transaction($connection) === false) |
|
123 | 123 | { |
124 | 124 | return; |
125 | 125 | } |
126 | 126 | } |
127 | 127 | else |
128 | 128 | { |
129 | - $this->_query("SAVE TRANS SP" . $transactionLevel, $connection); |
|
129 | + $this->_query("SAVE TRANS SP".$transactionLevel, $connection); |
|
130 | 130 | } |
131 | 131 | return true; |
132 | 132 | } |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | |
143 | 143 | $point = $transactionLevel - 1; |
144 | 144 | |
145 | - if($point) |
|
145 | + if ($point) |
|
146 | 146 | { |
147 | - $this->_query("ROLLBACK TRANS SP" . $point, $connection); |
|
147 | + $this->_query("ROLLBACK TRANS SP".$point, $connection); |
|
148 | 148 | } |
149 | 149 | else |
150 | 150 | { |
@@ -176,18 +176,18 @@ discard block |
||
176 | 176 | { |
177 | 177 | $_param = array(); |
178 | 178 | |
179 | - if(count($this->param)) |
|
179 | + if (count($this->param)) |
|
180 | 180 | { |
181 | - foreach($this->param as $k => $o) |
|
181 | + foreach ($this->param as $k => $o) |
|
182 | 182 | { |
183 | - if($o->isColumnName()) |
|
183 | + if ($o->isColumnName()) |
|
184 | 184 | { |
185 | 185 | continue; |
186 | 186 | } |
187 | - if($o->getType() == 'number') |
|
187 | + if ($o->getType() == 'number') |
|
188 | 188 | { |
189 | 189 | $value = $o->getUnescapedValue(); |
190 | - if(is_array($value)) |
|
190 | + if (is_array($value)) |
|
191 | 191 | { |
192 | 192 | $_param = array_merge($_param, $value); |
193 | 193 | } |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | else |
200 | 200 | { |
201 | 201 | $value = $o->getUnescapedValue(); |
202 | - if(is_array($value)) |
|
202 | + if (is_array($value)) |
|
203 | 203 | { |
204 | - foreach($value as $v) |
|
204 | + foreach ($value as $v) |
|
205 | 205 | { |
206 | 206 | $_param[] = array($v, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_STRING('utf-8')); |
207 | 207 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | |
217 | 217 | // Run the query statement |
218 | 218 | $result = false; |
219 | - if(count($_param)) |
|
219 | + if (count($_param)) |
|
220 | 220 | { |
221 | 221 | $args = $this->_getParametersByReference($_param); |
222 | 222 | $stmt = sqlsrv_prepare($connection, $query, $args); |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $stmt = sqlsrv_prepare($connection, $query); |
227 | 227 | } |
228 | 228 | |
229 | - if(!$stmt) |
|
229 | + if (!$stmt) |
|
230 | 230 | { |
231 | 231 | $result = false; |
232 | 232 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | } |
237 | 237 | |
238 | 238 | // Error Check |
239 | - if(!$result) |
|
239 | + if (!$result) |
|
240 | 240 | { |
241 | 241 | $this->setError(print_r(sqlsrv_errors(), true)); |
242 | 242 | } |
@@ -259,9 +259,9 @@ discard block |
||
259 | 259 | $copy = array(); |
260 | 260 | $args = array(); |
261 | 261 | $i = 0; |
262 | - foreach($_param as $key => $value) |
|
262 | + foreach ($_param as $key => $value) |
|
263 | 263 | { |
264 | - if(is_array($value)) |
|
264 | + if (is_array($value)) |
|
265 | 265 | { |
266 | 266 | $value_copy = $value; |
267 | 267 | $value_arg = array(); |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | function _fetch($result, $arrayIndexEndValue = NULL) |
289 | 289 | { |
290 | 290 | $output = array(); |
291 | - if(!$this->isConnected() || $this->isError() || !$result) |
|
291 | + if (!$this->isConnected() || $this->isError() || !$result) |
|
292 | 292 | { |
293 | 293 | return $output; |
294 | 294 | } |
@@ -296,18 +296,18 @@ discard block |
||
296 | 296 | $c = sqlsrv_num_fields($result); |
297 | 297 | $m = null; |
298 | 298 | |
299 | - while(sqlsrv_fetch($result)) |
|
299 | + while (sqlsrv_fetch($result)) |
|
300 | 300 | { |
301 | - if(!$m) |
|
301 | + if (!$m) |
|
302 | 302 | { |
303 | 303 | $m = sqlsrv_field_metadata($result); |
304 | 304 | } |
305 | 305 | unset($row); |
306 | - for($i = 0; $i < $c; $i++) |
|
306 | + for ($i = 0; $i < $c; $i++) |
|
307 | 307 | { |
308 | 308 | $row->{$m[$i]['Name']} = sqlsrv_get_field($result, $i, SQLSRV_PHPTYPE_STRING('utf-8')); |
309 | 309 | } |
310 | - if($arrayIndexEndValue) |
|
310 | + if ($arrayIndexEndValue) |
|
311 | 311 | { |
312 | 312 | $output[$arrayIndexEndValue--] = $row; |
313 | 313 | } |
@@ -317,9 +317,9 @@ discard block |
||
317 | 317 | } |
318 | 318 | } |
319 | 319 | |
320 | - if(count($output) == 1) |
|
320 | + if (count($output) == 1) |
|
321 | 321 | { |
322 | - if(isset($arrayIndexEndValue)) |
|
322 | + if (isset($arrayIndexEndValue)) |
|
323 | 323 | { |
324 | 324 | return $output; |
325 | 325 | } |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | $result = $this->_query($query); |
361 | 361 | $tmp = $this->_fetch($result); |
362 | 362 | |
363 | - if(!$tmp) |
|
363 | + if (!$tmp) |
|
364 | 364 | { |
365 | 365 | return false; |
366 | 366 | } |
@@ -379,18 +379,18 @@ discard block |
||
379 | 379 | */ |
380 | 380 | function addColumn($table_name, $column_name, $type = 'number', $size = '', $default = null, $notnull = false) |
381 | 381 | { |
382 | - if($this->isColumnExists($table_name, $column_name)) |
|
382 | + if ($this->isColumnExists($table_name, $column_name)) |
|
383 | 383 | { |
384 | 384 | return; |
385 | 385 | } |
386 | 386 | $type = $this->column_type[$type]; |
387 | - if(strtoupper($type) == 'INTEGER') |
|
387 | + if (strtoupper($type) == 'INTEGER') |
|
388 | 388 | { |
389 | 389 | $size = ''; |
390 | 390 | } |
391 | 391 | |
392 | 392 | $query = sprintf("alter table %s%s add \"%s\" ", $this->prefix, $table_name, $column_name); |
393 | - if($size) |
|
393 | + if ($size) |
|
394 | 394 | { |
395 | 395 | $query .= sprintf(" %s(%s) ", $type, $size); |
396 | 396 | } |
@@ -399,11 +399,11 @@ discard block |
||
399 | 399 | $query .= sprintf(" %s ", $type); |
400 | 400 | } |
401 | 401 | |
402 | - if(isset($default)) |
|
402 | + if (isset($default)) |
|
403 | 403 | { |
404 | 404 | $query .= sprintf(" default '%s' ", $default); |
405 | 405 | } |
406 | - if($notnull) |
|
406 | + if ($notnull) |
|
407 | 407 | { |
408 | 408 | $query .= " not null "; |
409 | 409 | } |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | */ |
420 | 420 | function dropColumn($table_name, $column_name) |
421 | 421 | { |
422 | - if(!$this->isColumnExists($table_name, $column_name)) |
|
422 | + if (!$this->isColumnExists($table_name, $column_name)) |
|
423 | 423 | { |
424 | 424 | return; |
425 | 425 | } |
@@ -437,12 +437,12 @@ discard block |
||
437 | 437 | { |
438 | 438 | $query = sprintf("select syscolumns.name as name from syscolumns, sysobjects where sysobjects.name = '%s%s' and sysobjects.id = syscolumns.id and syscolumns.name = '%s'", $this->prefix, $table_name, $column_name); |
439 | 439 | $result = $this->_query($query); |
440 | - if($this->isError()) |
|
440 | + if ($this->isError()) |
|
441 | 441 | { |
442 | 442 | return; |
443 | 443 | } |
444 | 444 | $tmp = $this->_fetch($result); |
445 | - if(!$tmp->name) |
|
445 | + if (!$tmp->name) |
|
446 | 446 | { |
447 | 447 | return false; |
448 | 448 | } |
@@ -461,11 +461,11 @@ discard block |
||
461 | 461 | */ |
462 | 462 | function addIndex($table_name, $index_name, $target_columns, $is_unique = false) |
463 | 463 | { |
464 | - if($this->isIndexExists($table_name, $index_name)) |
|
464 | + if ($this->isIndexExists($table_name, $index_name)) |
|
465 | 465 | { |
466 | 466 | return; |
467 | 467 | } |
468 | - if(!is_array($target_columns)) |
|
468 | + if (!is_array($target_columns)) |
|
469 | 469 | { |
470 | 470 | $target_columns = array($target_columns); |
471 | 471 | } |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | */ |
484 | 484 | function dropIndex($table_name, $index_name, $is_unique = false) |
485 | 485 | { |
486 | - if(!$this->isIndexExists($table_name, $index_name)) |
|
486 | + if (!$this->isIndexExists($table_name, $index_name)) |
|
487 | 487 | { |
488 | 488 | return; |
489 | 489 | } |
@@ -502,13 +502,13 @@ discard block |
||
502 | 502 | $query = sprintf("select sysindexes.name as name from sysindexes, sysobjects where sysobjects.name = '%s%s' and sysobjects.id = sysindexes.id and sysindexes.name = '%s'", $this->prefix, $table_name, $index_name); |
503 | 503 | |
504 | 504 | $result = $this->_query($query); |
505 | - if($this->isError()) |
|
505 | + if ($this->isError()) |
|
506 | 506 | { |
507 | 507 | return; |
508 | 508 | } |
509 | 509 | $tmp = $this->_fetch($result); |
510 | 510 | |
511 | - if(!$tmp->name) |
|
511 | + if (!$tmp->name) |
|
512 | 512 | { |
513 | 513 | return false; |
514 | 514 | } |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | */ |
533 | 533 | function createTableByXmlFile($file_name) |
534 | 534 | { |
535 | - if(!file_exists($file_name)) |
|
535 | + if (!file_exists($file_name)) |
|
536 | 536 | { |
537 | 537 | return; |
538 | 538 | } |
@@ -557,22 +557,22 @@ discard block |
||
557 | 557 | $xml_obj = $oXml->parse($xml_doc); |
558 | 558 | // Create a table schema |
559 | 559 | $table_name = $xml_obj->table->attrs->name; |
560 | - if($this->isTableExists($table_name)) |
|
560 | + if ($this->isTableExists($table_name)) |
|
561 | 561 | { |
562 | 562 | return; |
563 | 563 | } |
564 | 564 | |
565 | - if($table_name == 'sequence') |
|
565 | + if ($table_name == 'sequence') |
|
566 | 566 | { |
567 | - $table_name = $this->prefix . $table_name; |
|
567 | + $table_name = $this->prefix.$table_name; |
|
568 | 568 | $query = sprintf('create table %s ( sequence int identity(1,1), seq int )', $table_name); |
569 | 569 | return $this->_query($query); |
570 | 570 | } |
571 | 571 | else |
572 | 572 | { |
573 | - $table_name = $this->prefix . $table_name; |
|
573 | + $table_name = $this->prefix.$table_name; |
|
574 | 574 | |
575 | - if(!is_array($xml_obj->table->column)) |
|
575 | + if (!is_array($xml_obj->table->column)) |
|
576 | 576 | { |
577 | 577 | $columns[] = $xml_obj->table->column; |
578 | 578 | } |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | $index_list = array(); |
587 | 587 | |
588 | 588 | $typeList = array('number' => 1, 'text' => 1); |
589 | - foreach($columns as $column) |
|
589 | + foreach ($columns as $column) |
|
590 | 590 | { |
591 | 591 | $name = $column->attrs->name; |
592 | 592 | $type = $column->attrs->type; |
@@ -598,48 +598,48 @@ discard block |
||
598 | 598 | $default = $column->attrs->default; |
599 | 599 | $auto_increment = $column->attrs->auto_increment; |
600 | 600 | |
601 | - $column_schema[] = sprintf('[%s] %s%s %s %s %s', $name, $this->column_type[$type], !isset($typeList[$type]) && $size ? '(' . $size . ')' : '', isset($default) ? "default '" . $default . "'" : '', $notnull ? 'not null' : 'null', $auto_increment ? 'identity(1,1)' : ''); |
|
601 | + $column_schema[] = sprintf('[%s] %s%s %s %s %s', $name, $this->column_type[$type], !isset($typeList[$type]) && $size ? '('.$size.')' : '', isset($default) ? "default '".$default."'" : '', $notnull ? 'not null' : 'null', $auto_increment ? 'identity(1,1)' : ''); |
|
602 | 602 | |
603 | - if($primary_key) |
|
603 | + if ($primary_key) |
|
604 | 604 | { |
605 | 605 | $primary_list[] = $name; |
606 | 606 | } |
607 | - else if($unique) |
|
607 | + else if ($unique) |
|
608 | 608 | { |
609 | 609 | $unique_list[$unique][] = $name; |
610 | 610 | } |
611 | - else if($index) |
|
611 | + else if ($index) |
|
612 | 612 | { |
613 | 613 | $index_list[$index][] = $name; |
614 | 614 | } |
615 | 615 | } |
616 | 616 | |
617 | - if(count($primary_list)) |
|
617 | + if (count($primary_list)) |
|
618 | 618 | { |
619 | - $column_schema[] = sprintf("primary key (%s)", '"' . implode($primary_list, '","') . '"'); |
|
619 | + $column_schema[] = sprintf("primary key (%s)", '"'.implode($primary_list, '","').'"'); |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | $schema = sprintf('create table [%s] (%s%s)', $this->addQuotes($table_name), "\n", implode($column_schema, ",\n")); |
623 | 623 | $output = $this->_query($schema); |
624 | - if(!$output) |
|
624 | + if (!$output) |
|
625 | 625 | { |
626 | 626 | return false; |
627 | 627 | } |
628 | 628 | |
629 | - if(count($unique_list)) |
|
629 | + if (count($unique_list)) |
|
630 | 630 | { |
631 | - foreach($unique_list as $key => $val) |
|
631 | + foreach ($unique_list as $key => $val) |
|
632 | 632 | { |
633 | - $query = sprintf("create unique index %s on %s (%s);", $key, $table_name, '[' . implode('],[', $val) . ']'); |
|
633 | + $query = sprintf("create unique index %s on %s (%s);", $key, $table_name, '['.implode('],[', $val).']'); |
|
634 | 634 | $this->_query($query); |
635 | 635 | } |
636 | 636 | } |
637 | 637 | |
638 | - if(count($index_list)) |
|
638 | + if (count($index_list)) |
|
639 | 639 | { |
640 | - foreach($index_list as $key => $val) |
|
640 | + foreach ($index_list as $key => $val) |
|
641 | 641 | { |
642 | - $query = sprintf("create index %s on %s (%s);", $key, $table_name, '[' . implode('],[', $val) . ']'); |
|
642 | + $query = sprintf("create index %s on %s (%s);", $key, $table_name, '['.implode('],[', $val).']'); |
|
643 | 643 | $this->_query($query); |
644 | 644 | } |
645 | 645 | } |
@@ -682,34 +682,34 @@ discard block |
||
682 | 682 | function getUpdateSql($query, $with_values = true, $with_priority = false) |
683 | 683 | { |
684 | 684 | $columnsList = $query->getUpdateString($with_values); |
685 | - if($columnsList == '') |
|
685 | + if ($columnsList == '') |
|
686 | 686 | { |
687 | 687 | return new BaseObject(-1, "Invalid query"); |
688 | 688 | } |
689 | 689 | |
690 | 690 | $from = $query->getFromString($with_values); |
691 | - if($from == '') |
|
691 | + if ($from == '') |
|
692 | 692 | { |
693 | 693 | return new BaseObject(-1, "Invalid query"); |
694 | 694 | } |
695 | 695 | |
696 | 696 | $tables = $query->getTables(); |
697 | 697 | $alias_list = ''; |
698 | - foreach($tables as $table) |
|
698 | + foreach ($tables as $table) |
|
699 | 699 | { |
700 | 700 | $alias_list .= $table->getAlias(); |
701 | 701 | } |
702 | 702 | implode(',', explode(' ', $alias_list)); |
703 | 703 | |
704 | 704 | $where = $query->getWhereString($with_values); |
705 | - if($where != '') |
|
705 | + if ($where != '') |
|
706 | 706 | { |
707 | - $where = ' WHERE ' . $where; |
|
707 | + $where = ' WHERE '.$where; |
|
708 | 708 | } |
709 | 709 | |
710 | 710 | $priority = $with_priority ? $query->getPriority() : ''; |
711 | 711 | |
712 | - return "UPDATE $priority $alias_list SET $columnsList FROM " . $from . $where; |
|
712 | + return "UPDATE $priority $alias_list SET $columnsList FROM ".$from.$where; |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | /** |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | * @param boolean $with_values |
731 | 731 | * @return string |
732 | 732 | */ |
733 | - function getSelectSql($query, $with_values = TRUE, $connection=NULL) |
|
733 | + function getSelectSql($query, $with_values = TRUE, $connection = NULL) |
|
734 | 734 | { |
735 | 735 | $with_values = false; |
736 | 736 | |
@@ -740,75 +740,75 @@ discard block |
||
740 | 740 | $limit = ''; |
741 | 741 | $limitCount = ''; |
742 | 742 | $limitQueryPart = $query->getLimit(); |
743 | - if($limitQueryPart) |
|
743 | + if ($limitQueryPart) |
|
744 | 744 | { |
745 | 745 | $limitCount = $limitQueryPart->getLimit(); |
746 | 746 | } |
747 | - if($limitCount != '') |
|
747 | + if ($limitCount != '') |
|
748 | 748 | { |
749 | - $limit = 'SELECT TOP ' . $limitCount; |
|
749 | + $limit = 'SELECT TOP '.$limitCount; |
|
750 | 750 | } |
751 | 751 | |
752 | 752 | $select = $query->getSelectString($with_values); |
753 | - if($select == '') |
|
753 | + if ($select == '') |
|
754 | 754 | { |
755 | 755 | return new BaseObject(-1, "Invalid query"); |
756 | 756 | } |
757 | - if($limit != '') |
|
757 | + if ($limit != '') |
|
758 | 758 | { |
759 | - $select = $limit . ' ' . $select; |
|
759 | + $select = $limit.' '.$select; |
|
760 | 760 | } |
761 | 761 | else |
762 | 762 | { |
763 | - $select = 'SELECT ' . $select; |
|
763 | + $select = 'SELECT '.$select; |
|
764 | 764 | } |
765 | 765 | |
766 | 766 | $from = $query->getFromString($with_values); |
767 | - if($from == '') |
|
767 | + if ($from == '') |
|
768 | 768 | { |
769 | 769 | return new BaseObject(-1, "Invalid query"); |
770 | 770 | } |
771 | - $from = ' FROM ' . $from; |
|
771 | + $from = ' FROM '.$from; |
|
772 | 772 | |
773 | 773 | $where = $query->getWhereString($with_values); |
774 | - if($where != '') |
|
774 | + if ($where != '') |
|
775 | 775 | { |
776 | - $where = ' WHERE ' . $where; |
|
776 | + $where = ' WHERE '.$where; |
|
777 | 777 | } |
778 | 778 | |
779 | 779 | $groupBy = $query->getGroupByString(); |
780 | - if($groupBy != '') |
|
780 | + if ($groupBy != '') |
|
781 | 781 | { |
782 | - $groupBy = ' GROUP BY ' . $groupBy; |
|
782 | + $groupBy = ' GROUP BY '.$groupBy; |
|
783 | 783 | } |
784 | 784 | |
785 | 785 | $orderBy = $query->getOrderByString(); |
786 | - if($orderBy != '') |
|
786 | + if ($orderBy != '') |
|
787 | 787 | { |
788 | - $orderBy = ' ORDER BY ' . $orderBy; |
|
788 | + $orderBy = ' ORDER BY '.$orderBy; |
|
789 | 789 | } |
790 | 790 | |
791 | - if($limitCount != '' && $query->limit->start > 0) |
|
791 | + if ($limitCount != '' && $query->limit->start > 0) |
|
792 | 792 | { |
793 | 793 | $order = $query->getOrder(); |
794 | 794 | $first_columns = array(); |
795 | - foreach($order as $val) |
|
795 | + foreach ($order as $val) |
|
796 | 796 | { |
797 | 797 | $tmpColumnName = $val->getPureColumnName(); |
798 | - $first_columns[] = sprintf('%s(%s) as %s', $val->getPureSortOrder()=='asc'?'max':'min', $tmpColumnName, $tmpColumnName); |
|
798 | + $first_columns[] = sprintf('%s(%s) as %s', $val->getPureSortOrder() == 'asc' ? 'max' : 'min', $tmpColumnName, $tmpColumnName); |
|
799 | 799 | $first_sub_columns[] = $tmpColumnName; |
800 | 800 | } |
801 | 801 | |
802 | - $first_query = sprintf("select %s from (select top %d %s %s %s %s %s) xet", implode(',',$first_columns), $query->limit->start, implode(',',$first_sub_columns), $from, $where, $groupBy, $orderBy); |
|
802 | + $first_query = sprintf("select %s from (select top %d %s %s %s %s %s) xet", implode(',', $first_columns), $query->limit->start, implode(',', $first_sub_columns), $from, $where, $groupBy, $orderBy); |
|
803 | 803 | $this->param = $query->getArguments(); |
804 | 804 | $result = $this->__query($first_query, $connection); |
805 | 805 | $tmp = $this->_fetch($result); |
806 | 806 | |
807 | 807 | $sub_cond = array(); |
808 | - foreach($order as $k => $v) |
|
808 | + foreach ($order as $k => $v) |
|
809 | 809 | { |
810 | 810 | //for example... use Document |
811 | - if(get_class($v->sort_order) == 'SortArgument') |
|
811 | + if (get_class($v->sort_order) == 'SortArgument') |
|
812 | 812 | { |
813 | 813 | $sort_order = $v->sort_order->value; |
814 | 814 | } |
@@ -818,19 +818,19 @@ discard block |
||
818 | 818 | $sort_order = $v->sort_order; |
819 | 819 | } |
820 | 820 | |
821 | - $sub_cond[] = sprintf("%s %s '%s'", $v->getPureColumnName(), $sort_order=='asc'?'>':'<', $tmp->{$v->getPureColumnName()}); |
|
821 | + $sub_cond[] = sprintf("%s %s '%s'", $v->getPureColumnName(), $sort_order == 'asc' ? '>' : '<', $tmp->{$v->getPureColumnName()}); |
|
822 | 822 | } |
823 | 823 | |
824 | - if(!$where) |
|
824 | + if (!$where) |
|
825 | 825 | { |
826 | - $sub_condition = ' WHERE ( '.implode(' and ',$sub_cond).' )'; |
|
826 | + $sub_condition = ' WHERE ( '.implode(' and ', $sub_cond).' )'; |
|
827 | 827 | } |
828 | 828 | else |
829 | 829 | { |
830 | - $sub_condition = ' and ( '.implode(' and ',$sub_cond).' )'; |
|
830 | + $sub_condition = ' and ( '.implode(' and ', $sub_cond).' )'; |
|
831 | 831 | } |
832 | 832 | } |
833 | - return $select . ' ' . $from . ' ' . $where .$sub_condition. ' ' . $groupBy . ' ' . $orderBy; |
|
833 | + return $select.' '.$from.' '.$where.$sub_condition.' '.$groupBy.' '.$orderBy; |
|
834 | 834 | } |
835 | 835 | |
836 | 836 | /** |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | { |
846 | 846 | $query = $this->getSelectSql($queryObject, true, $connection); |
847 | 847 | |
848 | - if(strpos($query, "substr")) |
|
848 | + if (strpos($query, "substr")) |
|
849 | 849 | { |
850 | 850 | $query = str_replace("substr", "substring", $query); |
851 | 851 | } |
@@ -853,10 +853,10 @@ discard block |
||
853 | 853 | // TODO Decide if we continue to pass parameters like this |
854 | 854 | $this->param = $queryObject->getArguments(); |
855 | 855 | |
856 | - $query .= (__DEBUG_QUERY__ & 1 && $output->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
856 | + $query .= (__DEBUG_QUERY__ & 1 && $output->query_id) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
857 | 857 | $result = $this->_query($query, $connection); |
858 | 858 | |
859 | - if($this->isError()) |
|
859 | + if ($this->isError()) |
|
860 | 860 | { |
861 | 861 | return $this->queryError($queryObject); |
862 | 862 | } |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | function queryError($queryObject) |
885 | 885 | { |
886 | 886 | $limit = $queryObject->getLimit(); |
887 | - if($limit && $limit->isPageHandler()) |
|
887 | + if ($limit && $limit->isPageHandler()) |
|
888 | 888 | { |
889 | 889 | $buff = new BaseObject(); |
890 | 890 | $buff->total_count = 0; |
@@ -910,52 +910,52 @@ discard block |
||
910 | 910 | function queryPageLimit($queryObject, $result, $connection) |
911 | 911 | { |
912 | 912 | $limit = $queryObject->getLimit(); |
913 | - if($limit && $limit->isPageHandler()) |
|
913 | + if ($limit && $limit->isPageHandler()) |
|
914 | 914 | { |
915 | 915 | // Total count |
916 | 916 | $temp_where = $queryObject->getWhereString(true, false); |
917 | - $count_query = sprintf('select count(*) as "count" %s %s', 'FROM ' . $queryObject->getFromString(), ($temp_where === '' ? '' : ' WHERE ' . $temp_where)); |
|
917 | + $count_query = sprintf('select count(*) as "count" %s %s', 'FROM '.$queryObject->getFromString(), ($temp_where === '' ? '' : ' WHERE '.$temp_where)); |
|
918 | 918 | |
919 | 919 | // Check for distinct query and if found update count query structure |
920 | 920 | $temp_select = $queryObject->getSelectString(true); |
921 | 921 | $uses_distinct = stripos($temp_select, "distinct") !== false; |
922 | 922 | $uses_groupby = $queryObject->getGroupByString() != ''; |
923 | - if($uses_distinct || $uses_groupby) |
|
923 | + if ($uses_distinct || $uses_groupby) |
|
924 | 924 | { |
925 | 925 | $count_query = sprintf('select %s %s %s %s' |
926 | 926 | , $temp_select |
927 | - , 'FROM ' . $queryObject->getFromString(true) |
|
928 | - , ($temp_where === '' ? '' : ' WHERE ' . $temp_where) |
|
929 | - , ($uses_groupby ? ' GROUP BY ' . $queryObject->getGroupByString() : '') |
|
927 | + , 'FROM '.$queryObject->getFromString(true) |
|
928 | + , ($temp_where === '' ? '' : ' WHERE '.$temp_where) |
|
929 | + , ($uses_groupby ? ' GROUP BY '.$queryObject->getGroupByString() : '') |
|
930 | 930 | ); |
931 | 931 | |
932 | 932 | // If query uses grouping or distinct, count from original select |
933 | 933 | $count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query); |
934 | 934 | } |
935 | 935 | |
936 | - $count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
936 | + $count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
937 | 937 | $this->param = $queryObject->getArguments(); |
938 | 938 | $result_count = $this->_query($count_query, $connection); |
939 | 939 | $count_output = $this->_fetch($result_count); |
940 | 940 | $total_count = (int) $count_output->count; |
941 | 941 | |
942 | 942 | $list_count = $limit->list_count->getValue(); |
943 | - if(!$list_count) |
|
943 | + if (!$list_count) |
|
944 | 944 | { |
945 | 945 | $list_count = 20; |
946 | 946 | } |
947 | 947 | $page_count = $limit->page_count->getValue(); |
948 | - if(!$page_count) |
|
948 | + if (!$page_count) |
|
949 | 949 | { |
950 | 950 | $page_count = 10; |
951 | 951 | } |
952 | 952 | $page = $limit->page->getValue(); |
953 | - if(!$page || $page < 1) |
|
953 | + if (!$page || $page < 1) |
|
954 | 954 | { |
955 | 955 | $page = 1; |
956 | 956 | } |
957 | 957 | // Total pages |
958 | - if($total_count) |
|
958 | + if ($total_count) |
|
959 | 959 | { |
960 | 960 | $total_page = (int) (($total_count - 1) / $list_count) + 1; |
961 | 961 | } |
@@ -965,7 +965,7 @@ discard block |
||
965 | 965 | } |
966 | 966 | |
967 | 967 | // check the page variables |
968 | - if($page > $total_page) |
|
968 | + if ($page > $total_page) |
|
969 | 969 | { |
970 | 970 | // If requested page is bigger than total number of pages, return empty list |
971 | 971 | |
@@ -977,7 +977,7 @@ discard block |
||
977 | 977 | $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count); |
978 | 978 | return $buff; |
979 | 979 | |
980 | - if($queryObject->usesClickCount()) |
|
980 | + if ($queryObject->usesClickCount()) |
|
981 | 981 | { |
982 | 982 | $update_query = $this->getClickCountQuery($queryObject); |
983 | 983 | $this->_executeUpdateAct($update_query); |
@@ -45,7 +45,9 @@ discard block |
||
45 | 45 | function __construct($auto_connect = TRUE) |
46 | 46 | { |
47 | 47 | $this->_setDBInfo(); |
48 | - if($auto_connect) $this->_connect(); |
|
48 | + if($auto_connect) { |
|
49 | + $this->_connect(); |
|
50 | + } |
|
49 | 51 | } |
50 | 52 | |
51 | 53 | /** |
@@ -123,8 +125,7 @@ discard block |
||
123 | 125 | { |
124 | 126 | return; |
125 | 127 | } |
126 | - } |
|
127 | - else |
|
128 | + } else |
|
128 | 129 | { |
129 | 130 | $this->_query("SAVE TRANS SP" . $transactionLevel, $connection); |
130 | 131 | } |
@@ -145,8 +146,7 @@ discard block |
||
145 | 146 | if($point) |
146 | 147 | { |
147 | 148 | $this->_query("ROLLBACK TRANS SP" . $point, $connection); |
148 | - } |
|
149 | - else |
|
149 | + } else |
|
150 | 150 | { |
151 | 151 | sqlsrv_rollback($connection); |
152 | 152 | } |
@@ -190,13 +190,11 @@ discard block |
||
190 | 190 | if(is_array($value)) |
191 | 191 | { |
192 | 192 | $_param = array_merge($_param, $value); |
193 | - } |
|
194 | - else |
|
193 | + } else |
|
195 | 194 | { |
196 | 195 | $_param[] = $o->getUnescapedValue(); |
197 | 196 | } |
198 | - } |
|
199 | - else |
|
197 | + } else |
|
200 | 198 | { |
201 | 199 | $value = $o->getUnescapedValue(); |
202 | 200 | if(is_array($value)) |
@@ -205,8 +203,7 @@ discard block |
||
205 | 203 | { |
206 | 204 | $_param[] = array($v, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_STRING('utf-8')); |
207 | 205 | } |
208 | - } |
|
209 | - else |
|
206 | + } else |
|
210 | 207 | { |
211 | 208 | $_param[] = array($value, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_STRING('utf-8')); |
212 | 209 | } |
@@ -220,8 +217,7 @@ discard block |
||
220 | 217 | { |
221 | 218 | $args = $this->_getParametersByReference($_param); |
222 | 219 | $stmt = sqlsrv_prepare($connection, $query, $args); |
223 | - } |
|
224 | - else |
|
220 | + } else |
|
225 | 221 | { |
226 | 222 | $stmt = sqlsrv_prepare($connection, $query); |
227 | 223 | } |
@@ -229,8 +225,7 @@ discard block |
||
229 | 225 | if(!$stmt) |
230 | 226 | { |
231 | 227 | $result = false; |
232 | - } |
|
233 | - else |
|
228 | + } else |
|
234 | 229 | { |
235 | 230 | $result = sqlsrv_execute($stmt); |
236 | 231 | } |
@@ -268,8 +263,7 @@ discard block |
||
268 | 263 | $value_arg[] = &$value_copy[0]; |
269 | 264 | $value_arg[] = $value_copy[1]; |
270 | 265 | $value_arg[] = $value_copy[2]; |
271 | - } |
|
272 | - else |
|
266 | + } else |
|
273 | 267 | { |
274 | 268 | $value_arg = $value; |
275 | 269 | } |
@@ -310,8 +304,7 @@ discard block |
||
310 | 304 | if($arrayIndexEndValue) |
311 | 305 | { |
312 | 306 | $output[$arrayIndexEndValue--] = $row; |
313 | - } |
|
314 | - else |
|
307 | + } else |
|
315 | 308 | { |
316 | 309 | $output[] = $row; |
317 | 310 | } |
@@ -322,8 +315,7 @@ discard block |
||
322 | 315 | if(isset($arrayIndexEndValue)) |
323 | 316 | { |
324 | 317 | return $output; |
325 | - } |
|
326 | - else |
|
318 | + } else |
|
327 | 319 | { |
328 | 320 | return $output[0]; |
329 | 321 | } |
@@ -393,8 +385,7 @@ discard block |
||
393 | 385 | if($size) |
394 | 386 | { |
395 | 387 | $query .= sprintf(" %s(%s) ", $type, $size); |
396 | - } |
|
397 | - else |
|
388 | + } else |
|
398 | 389 | { |
399 | 390 | $query .= sprintf(" %s ", $type); |
400 | 391 | } |
@@ -567,16 +558,14 @@ discard block |
||
567 | 558 | $table_name = $this->prefix . $table_name; |
568 | 559 | $query = sprintf('create table %s ( sequence int identity(1,1), seq int )', $table_name); |
569 | 560 | return $this->_query($query); |
570 | - } |
|
571 | - else |
|
561 | + } else |
|
572 | 562 | { |
573 | 563 | $table_name = $this->prefix . $table_name; |
574 | 564 | |
575 | 565 | if(!is_array($xml_obj->table->column)) |
576 | 566 | { |
577 | 567 | $columns[] = $xml_obj->table->column; |
578 | - } |
|
579 | - else |
|
568 | + } else |
|
580 | 569 | { |
581 | 570 | $columns = $xml_obj->table->column; |
582 | 571 | } |
@@ -603,12 +592,10 @@ discard block |
||
603 | 592 | if($primary_key) |
604 | 593 | { |
605 | 594 | $primary_list[] = $name; |
606 | - } |
|
607 | - else if($unique) |
|
595 | + } else if($unique) |
|
608 | 596 | { |
609 | 597 | $unique_list[$unique][] = $name; |
610 | - } |
|
611 | - else if($index) |
|
598 | + } else if($index) |
|
612 | 599 | { |
613 | 600 | $index_list[$index][] = $name; |
614 | 601 | } |
@@ -757,8 +744,7 @@ discard block |
||
757 | 744 | if($limit != '') |
758 | 745 | { |
759 | 746 | $select = $limit . ' ' . $select; |
760 | - } |
|
761 | - else |
|
747 | + } else |
|
762 | 748 | { |
763 | 749 | $select = 'SELECT ' . $select; |
764 | 750 | } |
@@ -824,8 +810,7 @@ discard block |
||
824 | 810 | if(!$where) |
825 | 811 | { |
826 | 812 | $sub_condition = ' WHERE ( '.implode(' and ',$sub_cond).' )'; |
827 | - } |
|
828 | - else |
|
813 | + } else |
|
829 | 814 | { |
830 | 815 | $sub_condition = ' and ( '.implode(' and ',$sub_cond).' )'; |
831 | 816 | } |
@@ -859,8 +844,7 @@ discard block |
||
859 | 844 | if($this->isError()) |
860 | 845 | { |
861 | 846 | return $this->queryError($queryObject); |
862 | - } |
|
863 | - else |
|
847 | + } else |
|
864 | 848 | { |
865 | 849 | return $this->queryPageLimit($queryObject, $result, $connection); |
866 | 850 | } |
@@ -893,8 +877,7 @@ discard block |
||
893 | 877 | $buff->data = array(); |
894 | 878 | $buff->page_navigation = new PageHandler(/* $total_count */0, /* $total_page */1, /* $page */1, /* $page_count */10); //default page handler values |
895 | 879 | return $buff; |
896 | - } |
|
897 | - else |
|
880 | + } else |
|
898 | 881 | { |
899 | 882 | return; |
900 | 883 | } |
@@ -958,8 +941,7 @@ discard block |
||
958 | 941 | if($total_count) |
959 | 942 | { |
960 | 943 | $total_page = (int) (($total_count - 1) / $list_count) + 1; |
961 | - } |
|
962 | - else |
|
944 | + } else |
|
963 | 945 | { |
964 | 946 | $total_page = 1; |
965 | 947 | } |
@@ -995,8 +977,7 @@ discard block |
||
995 | 977 | $buff->page = $page; |
996 | 978 | $buff->data = $data; |
997 | 979 | $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count); |
998 | - } |
|
999 | - else |
|
980 | + } else |
|
1000 | 981 | { |
1001 | 982 | $data = $this->_fetch($result); |
1002 | 983 | $buff = new BaseObject(); |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | */ |
20 | 20 | function __construct($column_name, $argument, $operation, $pipe = "") |
21 | 21 | { |
22 | - if($argument === null) |
|
22 | + if ($argument === null) |
|
23 | 23 | { |
24 | 24 | $this->_show = false; |
25 | 25 | return; |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | function getArgument() |
32 | 32 | { |
33 | - if(!$this->show()) |
|
33 | + if (!$this->show()) |
|
34 | 34 | return; |
35 | 35 | return $this->argument; |
36 | 36 | } |
@@ -43,23 +43,23 @@ discard block |
||
43 | 43 | { |
44 | 44 | $value = $this->argument->getUnescapedValue(); |
45 | 45 | |
46 | - if(is_array($value)) |
|
46 | + if (is_array($value)) |
|
47 | 47 | { |
48 | 48 | $q = ''; |
49 | - foreach($value as $v) |
|
49 | + foreach ($value as $v) |
|
50 | 50 | { |
51 | 51 | $q .= '?,'; |
52 | 52 | } |
53 | - if($q !== '') |
|
53 | + if ($q !== '') |
|
54 | 54 | { |
55 | 55 | $q = substr($q, 0, -1); |
56 | 56 | } |
57 | - $q = '(' . $q . ')'; |
|
57 | + $q = '('.$q.')'; |
|
58 | 58 | } |
59 | 59 | else |
60 | 60 | { |
61 | 61 | // Prepared statements: column names should not be sent as query arguments, but instead concatenated to query string |
62 | - if($this->argument->isColumnName()) |
|
62 | + if ($this->argument->isColumnName()) |
|
63 | 63 | { |
64 | 64 | $q = $value; |
65 | 65 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $q = '?'; |
69 | 69 | } |
70 | 70 | } |
71 | - return $this->pipe . ' ' . $this->getConditionPart($q); |
|
71 | + return $this->pipe.' '.$this->getConditionPart($q); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -76,17 +76,17 @@ discard block |
||
76 | 76 | */ |
77 | 77 | function show() |
78 | 78 | { |
79 | - if(!isset($this->_show)) |
|
79 | + if (!isset($this->_show)) |
|
80 | 80 | { |
81 | - if(!$this->argument->isValid()) |
|
81 | + if (!$this->argument->isValid()) |
|
82 | 82 | { |
83 | 83 | $this->_show = false; |
84 | 84 | } |
85 | - if($this->_value === '\'\'') |
|
85 | + if ($this->_value === '\'\'') |
|
86 | 86 | { |
87 | 87 | $this->_show = false; |
88 | 88 | } |
89 | - if(!isset($this->_show)) |
|
89 | + if (!isset($this->_show)) |
|
90 | 90 | { |
91 | 91 | return parent::show(); |
92 | 92 | } |
@@ -30,8 +30,9 @@ discard block |
||
30 | 30 | |
31 | 31 | function getArgument() |
32 | 32 | { |
33 | - if(!$this->show()) |
|
34 | - return; |
|
33 | + if(!$this->show()) { |
|
34 | + return; |
|
35 | + } |
|
35 | 36 | return $this->argument; |
36 | 37 | } |
37 | 38 | |
@@ -55,15 +56,13 @@ discard block |
||
55 | 56 | $q = substr($q, 0, -1); |
56 | 57 | } |
57 | 58 | $q = '(' . $q . ')'; |
58 | - } |
|
59 | - else |
|
59 | + } else |
|
60 | 60 | { |
61 | 61 | // Prepared statements: column names should not be sent as query arguments, but instead concatenated to query string |
62 | 62 | if($this->argument->isColumnName()) |
63 | 63 | { |
64 | 64 | $q = $value; |
65 | - } |
|
66 | - else |
|
65 | + } else |
|
67 | 66 | { |
68 | 67 | $q = '?'; |
69 | 68 | } |
@@ -32,14 +32,14 @@ discard block |
||
32 | 32 | function __construct($conditions, $pipe = "") |
33 | 33 | { |
34 | 34 | $this->conditions = array(); |
35 | - foreach($conditions as $condition) |
|
35 | + foreach ($conditions as $condition) |
|
36 | 36 | { |
37 | - if($condition->show()) |
|
37 | + if ($condition->show()) |
|
38 | 38 | { |
39 | 39 | $this->conditions[] = $condition; |
40 | 40 | } |
41 | 41 | } |
42 | - if(count($this->conditions) === 0) |
|
42 | + if (count($this->conditions) === 0) |
|
43 | 43 | { |
44 | 44 | $this->_show = false; |
45 | 45 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | function setPipe($pipe) |
60 | 60 | { |
61 | - if($this->pipe !== $pipe) |
|
61 | + if ($this->pipe !== $pipe) |
|
62 | 62 | { |
63 | 63 | $this->_group = null; |
64 | 64 | } |
@@ -72,24 +72,24 @@ discard block |
||
72 | 72 | */ |
73 | 73 | function toString($with_value = true) |
74 | 74 | { |
75 | - if(!isset($this->_group)) |
|
75 | + if (!isset($this->_group)) |
|
76 | 76 | { |
77 | 77 | $cond_indx = 0; |
78 | 78 | $group = ''; |
79 | 79 | |
80 | - foreach($this->conditions as $condition) |
|
80 | + foreach ($this->conditions as $condition) |
|
81 | 81 | { |
82 | - if($cond_indx === 0) |
|
82 | + if ($cond_indx === 0) |
|
83 | 83 | { |
84 | 84 | $condition->setPipe(""); |
85 | 85 | } |
86 | - $group .= $condition->toString($with_value) . ' '; |
|
86 | + $group .= $condition->toString($with_value).' '; |
|
87 | 87 | $cond_indx++; |
88 | 88 | } |
89 | 89 | |
90 | - if($this->pipe !== "" && trim($group) !== '') |
|
90 | + if ($this->pipe !== "" && trim($group) !== '') |
|
91 | 91 | { |
92 | - $group = $this->pipe . ' (' . $group . ')'; |
|
92 | + $group = $this->pipe.' ('.$group.')'; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | $this->_group = $group; |
@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | function getArguments() |
105 | 105 | { |
106 | 106 | $args = array(); |
107 | - foreach($this->conditions as $condition) |
|
107 | + foreach ($this->conditions as $condition) |
|
108 | 108 | { |
109 | 109 | $arg = $condition->getArgument(); |
110 | - if($arg) |
|
110 | + if ($arg) |
|
111 | 111 | { |
112 | 112 | $args[] = $arg; |
113 | 113 | } |
@@ -42,8 +42,7 @@ |
||
42 | 42 | if(count($this->conditions) === 0) |
43 | 43 | { |
44 | 44 | $this->_show = false; |
45 | - } |
|
46 | - else |
|
45 | + } else |
|
47 | 46 | { |
48 | 47 | $this->_show = true; |
49 | 48 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | function isJoinTable() |
58 | 58 | { |
59 | - if($this->join_type) |
|
59 | + if ($this->join_type) |
|
60 | 60 | { |
61 | 61 | return true; |
62 | 62 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | { |
68 | 68 | $oDB = &DB::getInstance(); |
69 | 69 | |
70 | - return '(' . $oDB->getSelectSql($this, $with_values) . ')'; |
|
70 | + return '('.$oDB->getSelectSql($this, $with_values).')'; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | function isSubquery() |
@@ -38,21 +38,21 @@ |
||
38 | 38 | { |
39 | 39 | // TODO Escape value according to column type instead of variable type |
40 | 40 | $value = $this->argument; |
41 | - if(!is_numeric($value)) |
|
41 | + if (!is_numeric($value)) |
|
42 | 42 | { |
43 | - return "'" . $value . "'"; |
|
43 | + return "'".$value."'"; |
|
44 | 44 | } |
45 | 45 | return $value; |
46 | 46 | } |
47 | 47 | |
48 | 48 | function show() |
49 | 49 | { |
50 | - if(!$this->argument) |
|
50 | + if (!$this->argument) |
|
51 | 51 | { |
52 | 52 | return false; |
53 | 53 | } |
54 | 54 | $value = $this->argument; |
55 | - if(!isset($value)) |
|
55 | + if (!isset($value)) |
|
56 | 56 | { |
57 | 57 | return false; |
58 | 58 | } |
@@ -42,7 +42,7 @@ |
||
42 | 42 | */ |
43 | 43 | function getExpression() |
44 | 44 | { |
45 | - return sprintf("%s%s", $this->column_name, $this->column_alias ? " as " . $this->column_alias : ""); |
|
45 | + return sprintf("%s%s", $this->column_name, $this->column_alias ? " as ".$this->column_alias : ""); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | function show() |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | function getValue($with_values = true) |
33 | 33 | { |
34 | - if($with_values) |
|
34 | + if ($with_values) |
|
35 | 35 | { |
36 | 36 | return $this->argument->getValue(); |
37 | 37 | } |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | |
41 | 41 | function show() |
42 | 42 | { |
43 | - if(!$this->argument) |
|
43 | + if (!$this->argument) |
|
44 | 44 | { |
45 | 45 | return false; |
46 | 46 | } |
47 | 47 | $value = $this->argument->getValue(); |
48 | - if(!isset($value)) |
|
48 | + if (!isset($value)) |
|
49 | 49 | { |
50 | 50 | return false; |
51 | 51 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | function getArguments() |
61 | 61 | { |
62 | - if($this->argument) |
|
62 | + if ($this->argument) |
|
63 | 63 | { |
64 | 64 | return array($this->argument); |
65 | 65 | } |
@@ -62,8 +62,7 @@ |
||
62 | 62 | if($this->argument) |
63 | 63 | { |
64 | 64 | return array($this->argument); |
65 | - } |
|
66 | - else |
|
65 | + } else |
|
67 | 66 | { |
68 | 67 | return array(); |
69 | 68 | } |
@@ -42,16 +42,16 @@ |
||
42 | 42 | function getValue() |
43 | 43 | { |
44 | 44 | // TODO Escape value according to column type instead of variable type |
45 | - if(!is_numeric($this->value)) |
|
45 | + if (!is_numeric($this->value)) |
|
46 | 46 | { |
47 | - return "'" . $this->value . "'"; |
|
47 | + return "'".$this->value."'"; |
|
48 | 48 | } |
49 | 49 | return $this->value; |
50 | 50 | } |
51 | 51 | |
52 | 52 | function show() |
53 | 53 | { |
54 | - if(!$this->value) |
|
54 | + if (!$this->value) |
|
55 | 55 | { |
56 | 56 | return false; |
57 | 57 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | { |
28 | 28 | parent::__construct($column_name, $alias); |
29 | 29 | |
30 | - if(!is_bool($click_count)) |
|
30 | + if (!is_bool($click_count)) |
|
31 | 31 | { |
32 | 32 | // error_log("Click_count value for $column_name was not boolean", 0); |
33 | 33 | $this->click_count = false; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | function getExpression() |
48 | 48 | { |
49 | 49 | $db_type = Context::getDBType(); |
50 | - if($db_type == 'cubrid') |
|
50 | + if ($db_type == 'cubrid') |
|
51 | 51 | { |
52 | 52 | return "INCR($this->column_name)"; |
53 | 53 | } |
@@ -50,8 +50,7 @@ |
||
50 | 50 | if($db_type == 'cubrid') |
51 | 51 | { |
52 | 52 | return "INCR($this->column_name)"; |
53 | - } |
|
54 | - else |
|
53 | + } else |
|
55 | 54 | { |
56 | 55 | return "$this->column_name"; |
57 | 56 | } |