@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | */ |
21 | 21 | function getInstance($opt = null) |
22 | 22 | { |
23 | - if(!$GLOBALS['__CacheWincache__']) |
|
23 | + if (!$GLOBALS['__CacheWincache__']) |
|
24 | 24 | { |
25 | 25 | $GLOBALS['__CacheWincache__'] = new CacheWincache(); |
26 | 26 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | */ |
60 | 60 | function put($key, $buff, $valid_time = 0) |
61 | 61 | { |
62 | - if($valid_time == 0) |
|
62 | + if ($valid_time == 0) |
|
63 | 63 | { |
64 | 64 | $valid_time = $this->valid_time; |
65 | 65 | } |
@@ -78,13 +78,13 @@ discard block |
||
78 | 78 | { |
79 | 79 | $_key = md5(_XE_PATH_ . $key); |
80 | 80 | $obj = wincache_ucache_get($_key, $success); |
81 | - if(!$success || !is_array($obj)) |
|
81 | + if (!$success || !is_array($obj)) |
|
82 | 82 | { |
83 | 83 | return false; |
84 | 84 | } |
85 | 85 | unset($obj[1]); |
86 | 86 | |
87 | - if($modified_time > 0 && $modified_time > $obj[0]) |
|
87 | + if ($modified_time > 0 && $modified_time > $obj[0]) |
|
88 | 88 | { |
89 | 89 | $this->_delete($_key); |
90 | 90 | return false; |
@@ -105,12 +105,12 @@ discard block |
||
105 | 105 | { |
106 | 106 | $_key = md5(_XE_PATH_ . $key); |
107 | 107 | $obj = wincache_ucache_get($_key, $success); |
108 | - if(!$success || !is_array($obj)) |
|
108 | + if (!$success || !is_array($obj)) |
|
109 | 109 | { |
110 | 110 | return false; |
111 | 111 | } |
112 | 112 | |
113 | - if($modified_time > 0 && $modified_time > $obj[0]) |
|
113 | + if ($modified_time > 0 && $modified_time > $obj[0]) |
|
114 | 114 | { |
115 | 115 | $this->_delete($_key); |
116 | 116 | return false; |
@@ -327,8 +327,7 @@ discard block |
||
327 | 327 | if(!isset($this->priority_dbms[$a->db_type])) |
328 | 328 | { |
329 | 329 | $priority_a = 0; |
330 | - } |
|
331 | - else |
|
330 | + } else |
|
332 | 331 | { |
333 | 332 | $priority_a = $this->priority_dbms[$a->db_type]; |
334 | 333 | } |
@@ -336,8 +335,7 @@ discard block |
||
336 | 335 | if(!isset($this->priority_dbms[$b->db_type])) |
337 | 336 | { |
338 | 337 | $priority_b = 0; |
339 | - } |
|
340 | - else |
|
338 | + } else |
|
341 | 339 | { |
342 | 340 | $priority_b = $this->priority_dbms[$b->db_type]; |
343 | 341 | } |
@@ -371,8 +369,7 @@ discard block |
||
371 | 369 | if($type == 'master') |
372 | 370 | { |
373 | 371 | return $this->master_db["is_connected"] ? TRUE : FALSE; |
374 | - } |
|
375 | - else |
|
372 | + } else |
|
376 | 373 | { |
377 | 374 | return $this->slave_db[$indx]["is_connected"] ? TRUE : FALSE; |
378 | 375 | } |
@@ -450,8 +447,7 @@ discard block |
||
450 | 447 | $buff[] = print_r($log, TRUE); |
451 | 448 | @file_put_contents($log_file, implode("\n", $buff) . "\n\n", FILE_APPEND|LOCK_EX); |
452 | 449 | } |
453 | - } |
|
454 | - else |
|
450 | + } else |
|
455 | 451 | { |
456 | 452 | $log['result'] = 'Success'; |
457 | 453 | } |
@@ -540,8 +536,7 @@ discard block |
||
540 | 536 | $target = 'modules'; |
541 | 537 | $module = $id_args[0]; |
542 | 538 | $id = $id_args[1]; |
543 | - } |
|
544 | - elseif(count($id_args) == 3) |
|
539 | + } elseif(count($id_args) == 3) |
|
545 | 540 | { |
546 | 541 | $target = $id_args[0]; |
547 | 542 | $typeList = array('addons' => 1, 'widgets' => 1); |
@@ -615,7 +610,9 @@ discard block |
||
615 | 610 | { |
616 | 611 | global $lang; |
617 | 612 | |
618 | - if(!in_array($type, array('master','slave'))) $type = 'slave'; |
|
613 | + if(!in_array($type, array('master','slave'))) { |
|
614 | + $type = 'slave'; |
|
615 | + } |
|
619 | 616 | |
620 | 617 | if(!file_exists($cache_file)) |
621 | 618 | { |
@@ -661,8 +658,7 @@ discard block |
||
661 | 658 | if($this->isError()) |
662 | 659 | { |
663 | 660 | $output = $this->getError(); |
664 | - } |
|
665 | - else if(!is_a($output, 'Object') && !is_subclass_of($output, 'Object')) |
|
661 | + } else if(!is_a($output, 'Object') && !is_subclass_of($output, 'Object')) |
|
666 | 662 | { |
667 | 663 | $output = new Object(); |
668 | 664 | } |
@@ -1077,8 +1073,7 @@ discard block |
||
1077 | 1073 | if($type == 'master') |
1078 | 1074 | { |
1079 | 1075 | $connection = &$this->master_db; |
1080 | - } |
|
1081 | - else |
|
1076 | + } else |
|
1082 | 1077 | { |
1083 | 1078 | $connection = &$this->slave_db[$indx]; |
1084 | 1079 | } |
@@ -1173,8 +1168,7 @@ discard block |
||
1173 | 1168 | { |
1174 | 1169 | $this->transaction_started = FALSE; |
1175 | 1170 | $this->transactionNestedLevel = 0; |
1176 | - } |
|
1177 | - else |
|
1171 | + } else |
|
1178 | 1172 | { |
1179 | 1173 | $this->transactionNestedLevel--; |
1180 | 1174 | } |
@@ -1234,8 +1228,7 @@ discard block |
||
1234 | 1228 | ) |
1235 | 1229 | { |
1236 | 1230 | $this->slave_db[0] = &$this->master_db; |
1237 | - } |
|
1238 | - else |
|
1231 | + } else |
|
1239 | 1232 | { |
1240 | 1233 | $this->slave_db = $db_info->slave_db; |
1241 | 1234 | } |
@@ -1288,8 +1281,7 @@ discard block |
||
1288 | 1281 | if($type == 'master') |
1289 | 1282 | { |
1290 | 1283 | $connection = &$this->master_db; |
1291 | - } |
|
1292 | - else |
|
1284 | + } else |
|
1293 | 1285 | { |
1294 | 1286 | $connection = &$this->slave_db[$indx]; |
1295 | 1287 | } |
@@ -1284,7 +1284,7 @@ |
||
1284 | 1284 | /** |
1285 | 1285 | * Delete cached group data |
1286 | 1286 | * @return void |
1287 | - */ |
|
1287 | + */ |
|
1288 | 1288 | function _deleteMemberGroupCache($site_srl = 0) |
1289 | 1289 | { |
1290 | 1290 | //remove from cache |
@@ -141,24 +141,24 @@ discard block |
||
141 | 141 | */ |
142 | 142 | function &getInstance($db_type = NULL) |
143 | 143 | { |
144 | - if(!$db_type) |
|
144 | + if (!$db_type) |
|
145 | 145 | { |
146 | 146 | $db_type = Context::getDBType(); |
147 | 147 | } |
148 | - if(!$db_type && Context::isInstalled()) |
|
148 | + if (!$db_type && Context::isInstalled()) |
|
149 | 149 | { |
150 | 150 | return new Object(-1, 'msg_db_not_setted'); |
151 | 151 | } |
152 | 152 | |
153 | - if(!isset($GLOBALS['__DB__'])) |
|
153 | + if (!isset($GLOBALS['__DB__'])) |
|
154 | 154 | { |
155 | 155 | $GLOBALS['__DB__'] = array(); |
156 | 156 | } |
157 | - if(!isset($GLOBALS['__DB__'][$db_type])) |
|
157 | + if (!isset($GLOBALS['__DB__'][$db_type])) |
|
158 | 158 | { |
159 | 159 | $class_name = 'DB' . ucfirst($db_type); |
160 | 160 | $class_file = _XE_PATH_ . "classes/db/$class_name.class.php"; |
161 | - if(!file_exists($class_file)) |
|
161 | + if (!file_exists($class_file)) |
|
162 | 162 | { |
163 | 163 | return new Object(-1, 'msg_db_not_setted'); |
164 | 164 | } |
@@ -212,18 +212,18 @@ discard block |
||
212 | 212 | { |
213 | 213 | is_a($this, 'DB') ? $self = $this : $self = self::getInstance(); |
214 | 214 | |
215 | - if(!$self->supported_list) |
|
215 | + if (!$self->supported_list) |
|
216 | 216 | { |
217 | 217 | $oDB = new DB(); |
218 | 218 | $self->supported_list = $oDB->_getSupportedList(); |
219 | 219 | } |
220 | 220 | |
221 | 221 | $enableList = array(); |
222 | - if(is_array($self->supported_list)) |
|
222 | + if (is_array($self->supported_list)) |
|
223 | 223 | { |
224 | - foreach($self->supported_list AS $key => $value) |
|
224 | + foreach ($self->supported_list AS $key => $value) |
|
225 | 225 | { |
226 | - if($value->enable) |
|
226 | + if ($value->enable) |
|
227 | 227 | { |
228 | 228 | $enableList[] = $value; |
229 | 229 | } |
@@ -241,18 +241,18 @@ discard block |
||
241 | 241 | { |
242 | 242 | is_a($this, 'DB') ? $self = $this : $self = self::getInstance(); |
243 | 243 | |
244 | - if(!$self->supported_list) |
|
244 | + if (!$self->supported_list) |
|
245 | 245 | { |
246 | 246 | $oDB = new DB(); |
247 | 247 | $self->supported_list = $oDB->_getSupportedList(); |
248 | 248 | } |
249 | 249 | |
250 | 250 | $disableList = array(); |
251 | - if(is_array($self->supported_list)) |
|
251 | + if (is_array($self->supported_list)) |
|
252 | 252 | { |
253 | - foreach($self->supported_list AS $key => $value) |
|
253 | + foreach ($self->supported_list AS $key => $value) |
|
254 | 254 | { |
255 | - if(!$value->enable) |
|
255 | + if (!$value->enable) |
|
256 | 256 | { |
257 | 257 | $disableList[] = $value; |
258 | 258 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | function _getSupportedList() |
270 | 270 | { |
271 | 271 | static $get_supported_list = ''; |
272 | - if(is_array($get_supported_list)) |
|
272 | + if (is_array($get_supported_list)) |
|
273 | 273 | { |
274 | 274 | $this->supported_list = $get_supported_list; |
275 | 275 | return $this->supported_list; |
@@ -280,13 +280,13 @@ discard block |
||
280 | 280 | $supported_list = FileHandler::readDir($db_classes_path, $filter, TRUE); |
281 | 281 | |
282 | 282 | // after creating instance of class, check is supported |
283 | - for($i = 0; $i < count($supported_list); $i++) |
|
283 | + for ($i = 0; $i < count($supported_list); $i++) |
|
284 | 284 | { |
285 | 285 | $db_type = $supported_list[$i]; |
286 | 286 | |
287 | 287 | $class_name = sprintf("DB%s%s", strtoupper(substr($db_type, 0, 1)), strtolower(substr($db_type, 1))); |
288 | 288 | $class_file = sprintf(_XE_PATH_ . "classes/db/%s.class.php", $class_name); |
289 | - if(!file_exists($class_file)) |
|
289 | + if (!file_exists($class_file)) |
|
290 | 290 | { |
291 | 291 | continue; |
292 | 292 | } |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | require_once($class_file); |
296 | 296 | $oDB = new $class_name(); |
297 | 297 | |
298 | - if(!$oDB) |
|
298 | + if (!$oDB) |
|
299 | 299 | { |
300 | 300 | continue; |
301 | 301 | } |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | */ |
320 | 320 | function _sortDBMS($a, $b) |
321 | 321 | { |
322 | - if(!isset($this->priority_dbms[$a->db_type])) |
|
322 | + if (!isset($this->priority_dbms[$a->db_type])) |
|
323 | 323 | { |
324 | 324 | $priority_a = 0; |
325 | 325 | } |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | $priority_a = $this->priority_dbms[$a->db_type]; |
329 | 329 | } |
330 | 330 | |
331 | - if(!isset($this->priority_dbms[$b->db_type])) |
|
331 | + if (!isset($this->priority_dbms[$b->db_type])) |
|
332 | 332 | { |
333 | 333 | $priority_b = 0; |
334 | 334 | } |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | $priority_b = $this->priority_dbms[$b->db_type]; |
338 | 338 | } |
339 | 339 | |
340 | - if($priority_a == $priority_b) |
|
340 | + if ($priority_a == $priority_b) |
|
341 | 341 | { |
342 | 342 | return 0; |
343 | 343 | } |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | */ |
364 | 364 | function isConnected($type = 'master', $indx = 0) |
365 | 365 | { |
366 | - if($type == 'master') |
|
366 | + if ($type == 'master') |
|
367 | 367 | { |
368 | 368 | return $this->master_db["is_connected"] ? TRUE : FALSE; |
369 | 369 | } |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | */ |
393 | 393 | function actFinish() |
394 | 394 | { |
395 | - if(!$this->query) |
|
395 | + if (!$this->query) |
|
396 | 396 | { |
397 | 397 | return; |
398 | 398 | } |
@@ -413,37 +413,37 @@ discard block |
||
413 | 413 | |
414 | 414 | $bt = version_compare(PHP_VERSION, '5.3.6', '>=') ? debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) : debug_backtrace(); |
415 | 415 | |
416 | - foreach($bt as $no => $call) |
|
416 | + foreach ($bt as $no => $call) |
|
417 | 417 | { |
418 | - if($call['function'] == 'executeQuery' || $call['function'] == 'executeQueryArray') |
|
418 | + if ($call['function'] == 'executeQuery' || $call['function'] == 'executeQueryArray') |
|
419 | 419 | { |
420 | 420 | $call_no = $no; |
421 | 421 | $call_no++; |
422 | - $log['called_file'] = $bt[$call_no]['file'].':'.$bt[$call_no]['line']; |
|
423 | - $log['called_file'] = str_replace(_XE_PATH_ , '', $log['called_file']); |
|
422 | + $log['called_file'] = $bt[$call_no]['file'] . ':' . $bt[$call_no]['line']; |
|
423 | + $log['called_file'] = str_replace(_XE_PATH_, '', $log['called_file']); |
|
424 | 424 | $call_no++; |
425 | - $log['called_method'] = $bt[$call_no]['class'].$bt[$call_no]['type'].$bt[$call_no]['function']; |
|
425 | + $log['called_method'] = $bt[$call_no]['class'] . $bt[$call_no]['type'] . $bt[$call_no]['function']; |
|
426 | 426 | break; |
427 | 427 | } |
428 | 428 | } |
429 | 429 | |
430 | 430 | // leave error log if an error occured (if __DEBUG_DB_OUTPUT__ is defined) |
431 | - if($this->isError()) |
|
431 | + if ($this->isError()) |
|
432 | 432 | { |
433 | 433 | $log['result'] = 'Failed'; |
434 | 434 | $log['errno'] = $this->errno; |
435 | 435 | $log['errstr'] = $this->errstr; |
436 | 436 | |
437 | - if(__DEBUG_DB_OUTPUT__ == 1) |
|
437 | + if (__DEBUG_DB_OUTPUT__ == 1) |
|
438 | 438 | { |
439 | 439 | $debug_file = _XE_PATH_ . "files/_debug_db_query.php"; |
440 | 440 | $buff = array(); |
441 | - if(!file_exists($debug_file)) |
|
441 | + if (!file_exists($debug_file)) |
|
442 | 442 | { |
443 | 443 | $buff[] = '<?php exit(); ?' . '>'; |
444 | 444 | } |
445 | 445 | $buff[] = print_r($log, TRUE); |
446 | - @file_put_contents($log_file, implode("\n", $buff) . "\n\n", FILE_APPEND|LOCK_EX); |
|
446 | + @file_put_contents($log_file, implode("\n", $buff) . "\n\n", FILE_APPEND | LOCK_EX); |
|
447 | 447 | } |
448 | 448 | } |
449 | 449 | else |
@@ -514,11 +514,11 @@ discard block |
||
514 | 514 | { |
515 | 515 | static $cache_file = array(); |
516 | 516 | |
517 | - if(!$query_id) |
|
517 | + if (!$query_id) |
|
518 | 518 | { |
519 | 519 | return new Object(-1, 'msg_invalid_queryid'); |
520 | 520 | } |
521 | - if(!$this->db_type) |
|
521 | + if (!$this->db_type) |
|
522 | 522 | { |
523 | 523 | return; |
524 | 524 | } |
@@ -527,20 +527,20 @@ discard block |
||
527 | 527 | |
528 | 528 | $this->query_id = $query_id; |
529 | 529 | |
530 | - if(!isset($cache_file[$query_id]) || !file_exists($cache_file[$query_id])) |
|
530 | + if (!isset($cache_file[$query_id]) || !file_exists($cache_file[$query_id])) |
|
531 | 531 | { |
532 | 532 | $id_args = explode('.', $query_id); |
533 | - if(count($id_args) == 2) |
|
533 | + if (count($id_args) == 2) |
|
534 | 534 | { |
535 | 535 | $target = 'modules'; |
536 | 536 | $module = $id_args[0]; |
537 | 537 | $id = $id_args[1]; |
538 | 538 | } |
539 | - elseif(count($id_args) == 3) |
|
539 | + elseif (count($id_args) == 3) |
|
540 | 540 | { |
541 | 541 | $target = $id_args[0]; |
542 | 542 | $typeList = array('addons' => 1, 'widgets' => 1); |
543 | - if(!isset($typeList[$target])) |
|
543 | + if (!isset($typeList[$target])) |
|
544 | 544 | { |
545 | 545 | $this->actDBClassFinish(); |
546 | 546 | return; |
@@ -548,14 +548,14 @@ discard block |
||
548 | 548 | $module = $id_args[1]; |
549 | 549 | $id = $id_args[2]; |
550 | 550 | } |
551 | - if(!$target || !$module || !$id) |
|
551 | + if (!$target || !$module || !$id) |
|
552 | 552 | { |
553 | 553 | $this->actDBClassFinish(); |
554 | 554 | return new Object(-1, 'msg_invalid_queryid'); |
555 | 555 | } |
556 | 556 | |
557 | 557 | $xml_file = sprintf('%s%s/%s/queries/%s.xml', _XE_PATH_, $target, $module, $id); |
558 | - if(!file_exists($xml_file)) |
|
558 | + if (!file_exists($xml_file)) |
|
559 | 559 | { |
560 | 560 | $this->actDBClassFinish(); |
561 | 561 | return new Object(-1, 'msg_invalid_queryid'); |
@@ -583,13 +583,13 @@ discard block |
||
583 | 583 | $cache_file = sprintf('%s%s%s.%s.%s.cache.php', _XE_PATH_, $this->cache_file, $query_id, __ZBXE_VERSION__, $this->db_type); |
584 | 584 | |
585 | 585 | $cache_time = -1; |
586 | - if(file_exists($cache_file)) |
|
586 | + if (file_exists($cache_file)) |
|
587 | 587 | { |
588 | 588 | $cache_time = filemtime($cache_file); |
589 | 589 | } |
590 | 590 | |
591 | 591 | // if there is no cache file or is not new, find original xml query file and parse it |
592 | - if($cache_time < filemtime($xml_file) || $cache_time < filemtime(_XE_PATH_ . 'classes/db/DB.class.php') || $cache_time < filemtime(_XE_PATH_ . 'classes/xml/XmlQueryParser.class.php')) |
|
592 | + if ($cache_time < filemtime($xml_file) || $cache_time < filemtime(_XE_PATH_ . 'classes/db/DB.class.php') || $cache_time < filemtime(_XE_PATH_ . 'classes/xml/XmlQueryParser.class.php')) |
|
593 | 593 | { |
594 | 594 | $oParser = new XmlQueryParser(); |
595 | 595 | $oParser->parse($query_id, $xml_file, $cache_file); |
@@ -610,27 +610,27 @@ discard block |
||
610 | 610 | { |
611 | 611 | global $lang; |
612 | 612 | |
613 | - if(!in_array($type, array('master','slave'))) $type = 'slave'; |
|
613 | + if (!in_array($type, array('master', 'slave'))) $type = 'slave'; |
|
614 | 614 | |
615 | - if(!file_exists($cache_file)) |
|
615 | + if (!file_exists($cache_file)) |
|
616 | 616 | { |
617 | 617 | return new Object(-1, 'msg_invalid_queryid'); |
618 | 618 | } |
619 | 619 | |
620 | - if($source_args) |
|
620 | + if ($source_args) |
|
621 | 621 | { |
622 | 622 | $args = clone $source_args; |
623 | 623 | } |
624 | 624 | |
625 | 625 | $output = include($cache_file); |
626 | 626 | |
627 | - if((is_a($output, 'Object') || is_subclass_of($output, 'Object')) && !$output->toBool()) |
|
627 | + if ((is_a($output, 'Object') || is_subclass_of($output, 'Object')) && !$output->toBool()) |
|
628 | 628 | { |
629 | 629 | return $output; |
630 | 630 | } |
631 | 631 | |
632 | 632 | // execute appropriate query |
633 | - switch($output->getAction()) |
|
633 | + switch ($output->getAction()) |
|
634 | 634 | { |
635 | 635 | case 'insert' : |
636 | 636 | case 'insert-select' : |
@@ -653,11 +653,11 @@ discard block |
||
653 | 653 | break; |
654 | 654 | } |
655 | 655 | |
656 | - if($this->isError()) |
|
656 | + if ($this->isError()) |
|
657 | 657 | { |
658 | 658 | $output = $this->getError(); |
659 | 659 | } |
660 | - else if(!is_a($output, 'Object') && !is_subclass_of($output, 'Object')) |
|
660 | + else if (!is_a($output, 'Object') && !is_subclass_of($output, 'Object')) |
|
661 | 661 | { |
662 | 662 | $output = new Object(); |
663 | 663 | } |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | */ |
804 | 804 | function dropTable($table_name) |
805 | 805 | { |
806 | - if(!$table_name) |
|
806 | + if (!$table_name) |
|
807 | 807 | { |
808 | 808 | return; |
809 | 809 | } |
@@ -820,54 +820,54 @@ discard block |
||
820 | 820 | function getSelectSql($query, $with_values = TRUE) |
821 | 821 | { |
822 | 822 | $select = $query->getSelectString($with_values); |
823 | - if($select == '') |
|
823 | + if ($select == '') |
|
824 | 824 | { |
825 | 825 | return new Object(-1, "Invalid query"); |
826 | 826 | } |
827 | 827 | $select = 'SELECT ' . $select; |
828 | 828 | |
829 | 829 | $from = $query->getFromString($with_values); |
830 | - if($from == '') |
|
830 | + if ($from == '') |
|
831 | 831 | { |
832 | 832 | return new Object(-1, "Invalid query"); |
833 | 833 | } |
834 | 834 | $from = ' FROM ' . $from; |
835 | 835 | |
836 | 836 | $where = $query->getWhereString($with_values); |
837 | - if($where != '') |
|
837 | + if ($where != '') |
|
838 | 838 | { |
839 | 839 | $where = ' WHERE ' . $where; |
840 | 840 | } |
841 | 841 | |
842 | 842 | $tableObjects = $query->getTables(); |
843 | 843 | $index_hint_list = ''; |
844 | - foreach($tableObjects as $tableObject) |
|
844 | + foreach ($tableObjects as $tableObject) |
|
845 | 845 | { |
846 | - if(is_a($tableObject, 'CubridTableWithHint')) |
|
846 | + if (is_a($tableObject, 'CubridTableWithHint')) |
|
847 | 847 | { |
848 | 848 | $index_hint_list .= $tableObject->getIndexHintString() . ', '; |
849 | 849 | } |
850 | 850 | } |
851 | 851 | $index_hint_list = substr($index_hint_list, 0, -2); |
852 | - if($index_hint_list != '') |
|
852 | + if ($index_hint_list != '') |
|
853 | 853 | { |
854 | 854 | $index_hint_list = 'USING INDEX ' . $index_hint_list; |
855 | 855 | } |
856 | 856 | |
857 | 857 | $groupBy = $query->getGroupByString(); |
858 | - if($groupBy != '') |
|
858 | + if ($groupBy != '') |
|
859 | 859 | { |
860 | 860 | $groupBy = ' GROUP BY ' . $groupBy; |
861 | 861 | } |
862 | 862 | |
863 | 863 | $orderBy = $query->getOrderByString(); |
864 | - if($orderBy != '') |
|
864 | + if ($orderBy != '') |
|
865 | 865 | { |
866 | 866 | $orderBy = ' ORDER BY ' . $orderBy; |
867 | 867 | } |
868 | 868 | |
869 | 869 | $limit = $query->getLimitString(); |
870 | - if($limit != '') |
|
870 | + if ($limit != '') |
|
871 | 871 | { |
872 | 872 | $limit = ' LIMIT ' . $limit; |
873 | 873 | } |
@@ -890,7 +890,7 @@ discard block |
||
890 | 890 | { |
891 | 891 | $new_update_columns = array(); |
892 | 892 | $click_count_columns = $queryObject->getClickCountColumns(); |
893 | - foreach($click_count_columns as $click_count_column) |
|
893 | + foreach ($click_count_columns as $click_count_column) |
|
894 | 894 | { |
895 | 895 | $click_count_column_name = $click_count_column->column_name; |
896 | 896 | |
@@ -922,14 +922,14 @@ discard block |
||
922 | 922 | $sql .= $tables[0]->getAlias(); |
923 | 923 | |
924 | 924 | $from = $query->getFromString($with_values); |
925 | - if($from == '') |
|
925 | + if ($from == '') |
|
926 | 926 | { |
927 | 927 | return new Object(-1, "Invalid query"); |
928 | 928 | } |
929 | 929 | $sql .= ' FROM ' . $from; |
930 | 930 | |
931 | 931 | $where = $query->getWhereString($with_values); |
932 | - if($where != '') |
|
932 | + if ($where != '') |
|
933 | 933 | { |
934 | 934 | $sql .= ' WHERE ' . $where; |
935 | 935 | } |
@@ -947,19 +947,19 @@ discard block |
||
947 | 947 | function getUpdateSql($query, $with_values = TRUE, $with_priority = FALSE) |
948 | 948 | { |
949 | 949 | $columnsList = $query->getUpdateString($with_values); |
950 | - if($columnsList == '') |
|
950 | + if ($columnsList == '') |
|
951 | 951 | { |
952 | 952 | return new Object(-1, "Invalid query"); |
953 | 953 | } |
954 | 954 | |
955 | 955 | $tables = $query->getFromString($with_values); |
956 | - if($tables == '') |
|
956 | + if ($tables == '') |
|
957 | 957 | { |
958 | 958 | return new Object(-1, "Invalid query"); |
959 | 959 | } |
960 | 960 | |
961 | 961 | $where = $query->getWhereString($with_values); |
962 | - if($where != '') |
|
962 | + if ($where != '') |
|
963 | 963 | { |
964 | 964 | $where = ' WHERE ' . $where; |
965 | 965 | } |
@@ -1004,9 +1004,9 @@ discard block |
||
1004 | 1004 | */ |
1005 | 1005 | function _getConnection($type = 'master', $indx = NULL) |
1006 | 1006 | { |
1007 | - if($type == 'master') |
|
1007 | + if ($type == 'master') |
|
1008 | 1008 | { |
1009 | - if(!$this->master_db['is_connected']) |
|
1009 | + if (!$this->master_db['is_connected']) |
|
1010 | 1010 | { |
1011 | 1011 | $this->_connect($type); |
1012 | 1012 | } |
@@ -1014,12 +1014,12 @@ discard block |
||
1014 | 1014 | return $this->master_db["resource"]; |
1015 | 1015 | } |
1016 | 1016 | |
1017 | - if($indx === NULL) |
|
1017 | + if ($indx === NULL) |
|
1018 | 1018 | { |
1019 | 1019 | $indx = $this->_getSlaveConnectionStringIndex($type); |
1020 | 1020 | } |
1021 | 1021 | |
1022 | - if(!$this->slave_db[$indx]['is_connected']) |
|
1022 | + if (!$this->slave_db[$indx]['is_connected']) |
|
1023 | 1023 | { |
1024 | 1024 | $this->_connect($type, $indx); |
1025 | 1025 | } |
@@ -1034,11 +1034,11 @@ discard block |
||
1034 | 1034 | */ |
1035 | 1035 | function _dbInfoExists() |
1036 | 1036 | { |
1037 | - if(!$this->master_db) |
|
1037 | + if (!$this->master_db) |
|
1038 | 1038 | { |
1039 | 1039 | return FALSE; |
1040 | 1040 | } |
1041 | - if(count($this->slave_db) === 0) |
|
1041 | + if (count($this->slave_db) === 0) |
|
1042 | 1042 | { |
1043 | 1043 | return FALSE; |
1044 | 1044 | } |
@@ -1064,12 +1064,12 @@ discard block |
||
1064 | 1064 | */ |
1065 | 1065 | function close($type = 'master', $indx = 0) |
1066 | 1066 | { |
1067 | - if(!$this->isConnected($type, $indx)) |
|
1067 | + if (!$this->isConnected($type, $indx)) |
|
1068 | 1068 | { |
1069 | 1069 | return; |
1070 | 1070 | } |
1071 | 1071 | |
1072 | - if($type == 'master') |
|
1072 | + if ($type == 'master') |
|
1073 | 1073 | { |
1074 | 1074 | $connection = &$this->master_db; |
1075 | 1075 | } |
@@ -1100,12 +1100,12 @@ discard block |
||
1100 | 1100 | */ |
1101 | 1101 | function begin() |
1102 | 1102 | { |
1103 | - if(!$this->isConnected()) |
|
1103 | + if (!$this->isConnected()) |
|
1104 | 1104 | { |
1105 | 1105 | return; |
1106 | 1106 | } |
1107 | 1107 | |
1108 | - if($this->_begin($this->transactionNestedLevel)) |
|
1108 | + if ($this->_begin($this->transactionNestedLevel)) |
|
1109 | 1109 | { |
1110 | 1110 | $this->transaction_started = TRUE; |
1111 | 1111 | $this->transactionNestedLevel++; |
@@ -1128,15 +1128,15 @@ discard block |
||
1128 | 1128 | */ |
1129 | 1129 | function rollback() |
1130 | 1130 | { |
1131 | - if(!$this->isConnected() || !$this->transaction_started) |
|
1131 | + if (!$this->isConnected() || !$this->transaction_started) |
|
1132 | 1132 | { |
1133 | 1133 | return; |
1134 | 1134 | } |
1135 | - if($this->_rollback($this->transactionNestedLevel)) |
|
1135 | + if ($this->_rollback($this->transactionNestedLevel)) |
|
1136 | 1136 | { |
1137 | 1137 | $this->transactionNestedLevel--; |
1138 | 1138 | |
1139 | - if(!$this->transactionNestedLevel) |
|
1139 | + if (!$this->transactionNestedLevel) |
|
1140 | 1140 | { |
1141 | 1141 | $this->transaction_started = FALSE; |
1142 | 1142 | } |
@@ -1160,11 +1160,11 @@ discard block |
||
1160 | 1160 | */ |
1161 | 1161 | function commit($force = FALSE) |
1162 | 1162 | { |
1163 | - if(!$force && (!$this->isConnected() || !$this->transaction_started)) |
|
1163 | + if (!$force && (!$this->isConnected() || !$this->transaction_started)) |
|
1164 | 1164 | { |
1165 | 1165 | return; |
1166 | 1166 | } |
1167 | - if($this->transactionNestedLevel == 1 && $this->_commit()) |
|
1167 | + if ($this->transactionNestedLevel == 1 && $this->_commit()) |
|
1168 | 1168 | { |
1169 | 1169 | $this->transaction_started = FALSE; |
1170 | 1170 | $this->transactionNestedLevel = 0; |
@@ -1196,7 +1196,7 @@ discard block |
||
1196 | 1196 | */ |
1197 | 1197 | function _query($query, $connection = NULL) |
1198 | 1198 | { |
1199 | - if($connection == NULL) |
|
1199 | + if ($connection == NULL) |
|
1200 | 1200 | { |
1201 | 1201 | $connection = $this->_getConnection('master'); |
1202 | 1202 | } |
@@ -1221,7 +1221,7 @@ discard block |
||
1221 | 1221 | { |
1222 | 1222 | $db_info = Context::getDBInfo(); |
1223 | 1223 | $this->master_db = $db_info->master_db; |
1224 | - if($db_info->master_db["db_hostname"] == $db_info->slave_db[0]["db_hostname"] |
|
1224 | + if ($db_info->master_db["db_hostname"] == $db_info->slave_db[0]["db_hostname"] |
|
1225 | 1225 | && $db_info->master_db["db_port"] == $db_info->slave_db[0]["db_port"] |
1226 | 1226 | && $db_info->master_db["db_userid"] == $db_info->slave_db[0]["db_userid"] |
1227 | 1227 | && $db_info->master_db["db_password"] == $db_info->slave_db[0]["db_password"] |
@@ -1269,18 +1269,18 @@ discard block |
||
1269 | 1269 | */ |
1270 | 1270 | function _connect($type = 'master', $indx = 0) |
1271 | 1271 | { |
1272 | - if($this->isConnected($type, $indx)) |
|
1272 | + if ($this->isConnected($type, $indx)) |
|
1273 | 1273 | { |
1274 | 1274 | return; |
1275 | 1275 | } |
1276 | 1276 | |
1277 | 1277 | // Ignore if no DB information exists |
1278 | - if(!$this->_dbInfoExists()) |
|
1278 | + if (!$this->_dbInfoExists()) |
|
1279 | 1279 | { |
1280 | 1280 | return; |
1281 | 1281 | } |
1282 | 1282 | |
1283 | - if($type == 'master') |
|
1283 | + if ($type == 'master') |
|
1284 | 1284 | { |
1285 | 1285 | $connection = &$this->master_db; |
1286 | 1286 | } |
@@ -1290,7 +1290,7 @@ discard block |
||
1290 | 1290 | } |
1291 | 1291 | |
1292 | 1292 | $result = $this->__connect($connection); |
1293 | - if($result === NULL || $result === FALSE) |
|
1293 | + if ($result === NULL || $result === FALSE) |
|
1294 | 1294 | { |
1295 | 1295 | $connection["is_connected"] = FALSE; |
1296 | 1296 | return; |
@@ -1326,7 +1326,7 @@ discard block |
||
1326 | 1326 | */ |
1327 | 1327 | function actDBClassFinish() |
1328 | 1328 | { |
1329 | - if(!$this->query) |
|
1329 | + if (!$this->query) |
|
1330 | 1330 | { |
1331 | 1331 | return; |
1332 | 1332 | } |
@@ -1349,7 +1349,7 @@ discard block |
||
1349 | 1349 | function &getParser($force = FALSE) |
1350 | 1350 | { |
1351 | 1351 | static $dbParser = NULL; |
1352 | - if(!$dbParser || $force) |
|
1352 | + if (!$dbParser || $force) |
|
1353 | 1353 | { |
1354 | 1354 | $oDB = DB::getInstance(); |
1355 | 1355 | $dbParser = $oDB->getParser(); |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | * Returns counter cache data |
672 | 672 | * @param array|string $tables tables to get data |
673 | 673 | * @param string $condition condition to get data |
674 | - * @return int count of cache data |
|
674 | + * @return boolean count of cache data |
|
675 | 675 | */ |
676 | 676 | function getCountCache($tables, $condition) |
677 | 677 | { |
@@ -731,7 +731,7 @@ discard block |
||
731 | 731 | * @param array|string $tables tables to save data |
732 | 732 | * @param string $condition condition to save data |
733 | 733 | * @param int $count count of cache data to save |
734 | - * @return void |
|
734 | + * @return boolean |
|
735 | 735 | */ |
736 | 736 | function putCountCache($tables, $condition, $count = 0) |
737 | 737 | { |
@@ -1242,7 +1242,7 @@ discard block |
||
1242 | 1242 | * DB Connect |
1243 | 1243 | * this method is protected |
1244 | 1244 | * @param array $connection |
1245 | - * @return void |
|
1245 | + * @return resource |
|
1246 | 1246 | */ |
1247 | 1247 | function __connect($connection) |
1248 | 1248 | { |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | function __connect($connection) |
45 | 45 | { |
46 | 46 | // Attempt to connect |
47 | - if($connection["db_port"]) |
|
47 | + if ($connection["db_port"]) |
|
48 | 48 | { |
49 | 49 | $result = @mysqli_connect($connection["db_hostname"] |
50 | 50 | , $connection["db_userid"] |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | , $connection["db_database"]); |
61 | 61 | } |
62 | 62 | $error = mysqli_connect_errno(); |
63 | - if($error) |
|
63 | + if ($error) |
|
64 | 64 | { |
65 | 65 | $this->setError($error, mysqli_connect_error()); |
66 | 66 | return; |
@@ -87,11 +87,11 @@ discard block |
||
87 | 87 | */ |
88 | 88 | function addQuotes($string) |
89 | 89 | { |
90 | - if(version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc()) |
|
90 | + if (version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc()) |
|
91 | 91 | { |
92 | 92 | $string = stripslashes(str_replace("\\", "\\\\", $string)); |
93 | 93 | } |
94 | - if(!is_numeric($string)) |
|
94 | + if (!is_numeric($string)) |
|
95 | 95 | { |
96 | 96 | $connection = $this->_getConnection('master'); |
97 | 97 | $string = mysqli_escape_string($connection, $string); |
@@ -108,23 +108,23 @@ discard block |
||
108 | 108 | */ |
109 | 109 | function __query($query, $connection) |
110 | 110 | { |
111 | - if($this->use_prepared_statements == 'Y') |
|
111 | + if ($this->use_prepared_statements == 'Y') |
|
112 | 112 | { |
113 | 113 | // 1. Prepare query |
114 | 114 | $stmt = mysqli_prepare($connection, $query); |
115 | - if($stmt) |
|
115 | + if ($stmt) |
|
116 | 116 | { |
117 | 117 | $types = ''; |
118 | 118 | $params = array(); |
119 | 119 | $this->_prepareQueryParameters($types, $params); |
120 | 120 | |
121 | - if(!empty($params)) |
|
121 | + if (!empty($params)) |
|
122 | 122 | { |
123 | 123 | $args[0] = $stmt; |
124 | 124 | $args[1] = $types; |
125 | 125 | |
126 | 126 | $i = 2; |
127 | - foreach($params as $key => $param) |
|
127 | + foreach ($params as $key => $param) |
|
128 | 128 | { |
129 | 129 | $copy[$key] = $param; |
130 | 130 | $args[$i++] = &$copy[$key]; |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | |
133 | 133 | // 2. Bind parameters |
134 | 134 | $status = call_user_func_array('mysqli_stmt_bind_param', $args); |
135 | - if(!$status) |
|
135 | + if (!$status) |
|
136 | 136 | { |
137 | 137 | $this->setError(-1, "Invalid arguments: $query" . mysqli_error($connection) . PHP_EOL . print_r($args, true)); |
138 | 138 | } |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | // 3. Execute query |
142 | 142 | $status = mysqli_stmt_execute($stmt); |
143 | 143 | |
144 | - if(!$status) |
|
144 | + if (!$status) |
|
145 | 145 | { |
146 | 146 | $this->setError(-1, "Prepared statement failed: $query" . mysqli_error($connection) . PHP_EOL . print_r($args, true)); |
147 | 147 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $result = mysqli_query($connection, $query); |
156 | 156 | // Error Check |
157 | 157 | $error = mysqli_error($connection); |
158 | - if($error) |
|
158 | + if ($error) |
|
159 | 159 | { |
160 | 160 | $this->setError(mysqli_errno($connection), $error); |
161 | 161 | } |
@@ -174,23 +174,23 @@ discard block |
||
174 | 174 | { |
175 | 175 | $types = ''; |
176 | 176 | $params = array(); |
177 | - if(!$this->param) |
|
177 | + if (!$this->param) |
|
178 | 178 | { |
179 | 179 | return; |
180 | 180 | } |
181 | 181 | |
182 | - foreach($this->param as $k => $o) |
|
182 | + foreach ($this->param as $k => $o) |
|
183 | 183 | { |
184 | 184 | $value = $o->getUnescapedValue(); |
185 | 185 | $type = $o->getType(); |
186 | 186 | |
187 | 187 | // Skip column names -> this should be concatenated to query string |
188 | - if($o->isColumnName()) |
|
188 | + if ($o->isColumnName()) |
|
189 | 189 | { |
190 | 190 | continue; |
191 | 191 | } |
192 | 192 | |
193 | - switch($type) |
|
193 | + switch ($type) |
|
194 | 194 | { |
195 | 195 | case 'number' : |
196 | 196 | $type = 'i'; |
@@ -202,9 +202,9 @@ discard block |
||
202 | 202 | $type = 's'; |
203 | 203 | } |
204 | 204 | |
205 | - if(is_array($value)) |
|
205 | + if (is_array($value)) |
|
206 | 206 | { |
207 | - foreach($value as $v) |
|
207 | + foreach ($value as $v) |
|
208 | 208 | { |
209 | 209 | $params[] = $v; |
210 | 210 | $types .= $type; |
@@ -226,12 +226,12 @@ discard block |
||
226 | 226 | */ |
227 | 227 | function _fetch($result, $arrayIndexEndValue = NULL) |
228 | 228 | { |
229 | - if($this->use_prepared_statements != 'Y') |
|
229 | + if ($this->use_prepared_statements != 'Y') |
|
230 | 230 | { |
231 | 231 | return parent::_fetch($result, $arrayIndexEndValue); |
232 | 232 | } |
233 | 233 | $output = array(); |
234 | - if(!$this->isConnected() || $this->isError() || !$result) |
|
234 | + if (!$this->isConnected() || $this->isError() || !$result) |
|
235 | 235 | { |
236 | 236 | return $output; |
237 | 237 | } |
@@ -247,9 +247,9 @@ discard block |
||
247 | 247 | * MYSQLI_TYPE for longtext is 252 |
248 | 248 | */ |
249 | 249 | $longtext_exists = false; |
250 | - foreach($fields as $field) |
|
250 | + foreach ($fields as $field) |
|
251 | 251 | { |
252 | - if(isset($resultArray[$field->name])) // When joined tables are used and the same column name appears twice, we should add it separately, otherwise bind_result fails |
|
252 | + if (isset($resultArray[$field->name])) // When joined tables are used and the same column name appears twice, we should add it separately, otherwise bind_result fails |
|
253 | 253 | { |
254 | 254 | $field->name = 'repeat_' . $field->name; |
255 | 255 | } |
@@ -258,14 +258,14 @@ discard block |
||
258 | 258 | $row[$field->name] = ""; |
259 | 259 | $resultArray[$field->name] = &$row[$field->name]; |
260 | 260 | |
261 | - if($field->type == 252) |
|
261 | + if ($field->type == 252) |
|
262 | 262 | { |
263 | 263 | $longtext_exists = true; |
264 | 264 | } |
265 | 265 | } |
266 | 266 | $resultArray = array_merge(array($stmt), $resultArray); |
267 | 267 | |
268 | - if($longtext_exists) |
|
268 | + if ($longtext_exists) |
|
269 | 269 | { |
270 | 270 | mysqli_stmt_store_result($stmt); |
271 | 271 | } |
@@ -273,17 +273,17 @@ discard block |
||
273 | 273 | call_user_func_array('mysqli_stmt_bind_result', $resultArray); |
274 | 274 | |
275 | 275 | $rows = array(); |
276 | - while(mysqli_stmt_fetch($stmt)) |
|
276 | + while (mysqli_stmt_fetch($stmt)) |
|
277 | 277 | { |
278 | 278 | $resultObject = new stdClass(); |
279 | 279 | |
280 | - foreach($resultArray as $key => $value) |
|
280 | + foreach ($resultArray as $key => $value) |
|
281 | 281 | { |
282 | - if($key === 0) |
|
282 | + if ($key === 0) |
|
283 | 283 | { |
284 | 284 | continue; // Skip stmt object |
285 | 285 | } |
286 | - if(strpos($key, 'repeat_')) |
|
286 | + if (strpos($key, 'repeat_')) |
|
287 | 287 | { |
288 | 288 | $key = substr($key, 6); |
289 | 289 | } |
@@ -295,9 +295,9 @@ discard block |
||
295 | 295 | |
296 | 296 | mysqli_stmt_close($stmt); |
297 | 297 | |
298 | - if($arrayIndexEndValue) |
|
298 | + if ($arrayIndexEndValue) |
|
299 | 299 | { |
300 | - foreach($rows as $row) |
|
300 | + foreach ($rows as $row) |
|
301 | 301 | { |
302 | 302 | $output[$arrayIndexEndValue--] = $row; |
303 | 303 | } |
@@ -307,9 +307,9 @@ discard block |
||
307 | 307 | $output = $rows; |
308 | 308 | } |
309 | 309 | |
310 | - if(count($output) == 1) |
|
310 | + if (count($output) == 1) |
|
311 | 311 | { |
312 | - if(isset($arrayIndexEndValue)) |
|
312 | + if (isset($arrayIndexEndValue)) |
|
313 | 313 | { |
314 | 314 | return $output; |
315 | 315 | } |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | */ |
331 | 331 | function _executeInsertAct($queryObject, $with_values = false) |
332 | 332 | { |
333 | - if($this->use_prepared_statements != 'Y') |
|
333 | + if ($this->use_prepared_statements != 'Y') |
|
334 | 334 | { |
335 | 335 | return parent::_executeInsertAct($queryObject); |
336 | 336 | } |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | */ |
349 | 349 | function _executeUpdateAct($queryObject, $with_values = false) |
350 | 350 | { |
351 | - if($this->use_prepared_statements != 'Y') |
|
351 | + if ($this->use_prepared_statements != 'Y') |
|
352 | 352 | { |
353 | 353 | return parent::_executeUpdateAct($queryObject); |
354 | 354 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | */ |
367 | 367 | function _executeDeleteAct($queryObject, $with_values = false) |
368 | 368 | { |
369 | - if($this->use_prepared_statements != 'Y') |
|
369 | + if ($this->use_prepared_statements != 'Y') |
|
370 | 370 | { |
371 | 371 | return parent::_executeDeleteAct($queryObject); |
372 | 372 | } |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | */ |
388 | 388 | function _executeSelectAct($queryObject, $connection = null, $with_values = false) |
389 | 389 | { |
390 | - if($this->use_prepared_statements != 'Y') |
|
390 | + if ($this->use_prepared_statements != 'Y') |
|
391 | 391 | { |
392 | 392 | return parent::_executeSelectAct($queryObject, $connection); |
393 | 393 | } |
@@ -51,8 +51,7 @@ discard block |
||
51 | 51 | , $connection["db_password"] |
52 | 52 | , $connection["db_database"] |
53 | 53 | , $connection["db_port"]); |
54 | - } |
|
55 | - else |
|
54 | + } else |
|
56 | 55 | { |
57 | 56 | $result = @mysqli_connect($connection["db_hostname"] |
58 | 57 | , $connection["db_userid"] |
@@ -209,8 +208,7 @@ discard block |
||
209 | 208 | $params[] = $v; |
210 | 209 | $types .= $type; |
211 | 210 | } |
212 | - } |
|
213 | - else |
|
211 | + } else |
|
214 | 212 | { |
215 | 213 | $params[] = $value; |
216 | 214 | $types .= $type; |
@@ -249,10 +247,12 @@ discard block |
||
249 | 247 | $longtext_exists = false; |
250 | 248 | foreach($fields as $field) |
251 | 249 | { |
252 | - if(isset($resultArray[$field->name])) // When joined tables are used and the same column name appears twice, we should add it separately, otherwise bind_result fails |
|
250 | + if(isset($resultArray[$field->name])) { |
|
251 | + // When joined tables are used and the same column name appears twice, we should add it separately, otherwise bind_result fails |
|
253 | 252 | { |
254 | 253 | $field->name = 'repeat_' . $field->name; |
255 | 254 | } |
255 | + } |
|
256 | 256 | |
257 | 257 | // Array passed needs to contain references, not values |
258 | 258 | $row[$field->name] = ""; |
@@ -301,8 +301,7 @@ discard block |
||
301 | 301 | { |
302 | 302 | $output[$arrayIndexEndValue--] = $row; |
303 | 303 | } |
304 | - } |
|
305 | - else |
|
304 | + } else |
|
306 | 305 | { |
307 | 306 | $output = $rows; |
308 | 307 | } |
@@ -312,8 +311,7 @@ discard block |
||
312 | 311 | if(isset($arrayIndexEndValue)) |
313 | 312 | { |
314 | 313 | return $output; |
315 | - } |
|
316 | - else |
|
314 | + } else |
|
317 | 315 | { |
318 | 316 | return $output[0]; |
319 | 317 | } |
@@ -30,7 +30,7 @@ |
||
30 | 30 | /** |
31 | 31 | * Search Result |
32 | 32 | * |
33 | - * @return Object |
|
33 | + * @return Object|null |
|
34 | 34 | */ |
35 | 35 | function IS() |
36 | 36 | { |
@@ -56,7 +56,7 @@ |
||
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 | } |
@@ -32,14 +32,14 @@ discard block |
||
32 | 32 | function ConditionGroup($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,14 +72,14 @@ 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 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $cond_indx++; |
88 | 88 | } |
89 | 89 | |
90 | - if($this->pipe !== "" && trim($group) !== '') |
|
90 | + if ($this->pipe !== "" && trim($group) !== '') |
|
91 | 91 | { |
92 | 92 | $group = $this->pipe . ' (' . $group . ')'; |
93 | 93 | } |
@@ -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 | } |
@@ -111,8 +111,7 @@ |
||
111 | 111 | if($this->limit) |
112 | 112 | { |
113 | 113 | return $this->limit->toString(); |
114 | - } |
|
115 | - else |
|
114 | + } else |
|
116 | 115 | { |
117 | 116 | return ""; |
118 | 117 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | */ |
20 | 20 | function ConditionWithArgument($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,14 +43,14 @@ 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 | } |
@@ -59,7 +59,7 @@ discard block |
||
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 | } |
@@ -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 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | { |
28 | 28 | parent::SelectExpression($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 | } |
@@ -111,8 +111,7 @@ |
||
111 | 111 | if($this->limit) |
112 | 112 | { |
113 | 113 | return $this->limit->toString(); |
114 | - } |
|
115 | - else |
|
114 | + } else |
|
116 | 115 | { |
117 | 116 | return ""; |
118 | 117 | } |
@@ -42,7 +42,7 @@ discard block |
||
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 | 47 | return "'" . $this->value . "'"; |
48 | 48 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | function show() |
53 | 53 | { |
54 | - if(!$this->value) |
|
54 | + if (!$this->value) |
|
55 | 55 | { |
56 | 56 | return false; |
57 | 57 | } |
@@ -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 | } |
@@ -111,8 +111,7 @@ |
||
111 | 111 | if($this->limit) |
112 | 112 | { |
113 | 113 | return $this->limit->toString(); |
114 | - } |
|
115 | - else |
|
114 | + } else |
|
116 | 115 | { |
117 | 116 | return ""; |
118 | 117 | } |