@@ -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 | - $class_name = 'DB' . ucfirst($db_type); |
|
| 160 | - $class_file = _XE_PATH_ . "classes/db/$class_name.class.php"; |
|
| 161 | - if(!file_exists($class_file)) |
|
| 159 | + $class_name = 'DB'.ucfirst($db_type); |
|
| 160 | + $class_file = _XE_PATH_."classes/db/$class_name.class.php"; |
|
| 161 | + if (!file_exists($class_file)) |
|
| 162 | 162 | { |
| 163 | 163 | return new Object(-1, 'msg_db_not_setted'); |
| 164 | 164 | } |
@@ -187,8 +187,8 @@ discard block |
||
| 187 | 187 | */ |
| 188 | 188 | function DB() |
| 189 | 189 | { |
| 190 | - $this->count_cache_path = _XE_PATH_ . $this->count_cache_path; |
|
| 191 | - $this->cache_file = _XE_PATH_ . $this->cache_file; |
|
| 190 | + $this->count_cache_path = _XE_PATH_.$this->count_cache_path; |
|
| 191 | + $this->cache_file = _XE_PATH_.$this->cache_file; |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | /** |
@@ -210,18 +210,18 @@ discard block |
||
| 210 | 210 | */ |
| 211 | 211 | public static function getEnableList() |
| 212 | 212 | { |
| 213 | - if(!self::$supported_list) |
|
| 213 | + if (!self::$supported_list) |
|
| 214 | 214 | { |
| 215 | 215 | $oDB = new DB(); |
| 216 | 216 | self::$supported_list = $oDB->_getSupportedList(); |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | $enableList = array(); |
| 220 | - if(is_array(self::$supported_list)) |
|
| 220 | + if (is_array(self::$supported_list)) |
|
| 221 | 221 | { |
| 222 | - foreach(self::$supported_list AS $key => $value) |
|
| 222 | + foreach (self::$supported_list AS $key => $value) |
|
| 223 | 223 | { |
| 224 | - if($value->enable) |
|
| 224 | + if ($value->enable) |
|
| 225 | 225 | { |
| 226 | 226 | $enableList[] = $value; |
| 227 | 227 | } |
@@ -237,18 +237,18 @@ discard block |
||
| 237 | 237 | */ |
| 238 | 238 | public static function getDisableList() |
| 239 | 239 | { |
| 240 | - if(!self::$supported_list) |
|
| 240 | + if (!self::$supported_list) |
|
| 241 | 241 | { |
| 242 | 242 | $oDB = new DB(); |
| 243 | 243 | self::$supported_list = $oDB->_getSupportedList(); |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | $disableList = array(); |
| 247 | - if(is_array(self::$supported_list)) |
|
| 247 | + if (is_array(self::$supported_list)) |
|
| 248 | 248 | { |
| 249 | - foreach(self::$supported_list AS $key => $value) |
|
| 249 | + foreach (self::$supported_list AS $key => $value) |
|
| 250 | 250 | { |
| 251 | - if(!$value->enable) |
|
| 251 | + if (!$value->enable) |
|
| 252 | 252 | { |
| 253 | 253 | $disableList[] = $value; |
| 254 | 254 | } |
@@ -265,24 +265,24 @@ discard block |
||
| 265 | 265 | function _getSupportedList() |
| 266 | 266 | { |
| 267 | 267 | static $get_supported_list = ''; |
| 268 | - if(is_array($get_supported_list)) |
|
| 268 | + if (is_array($get_supported_list)) |
|
| 269 | 269 | { |
| 270 | 270 | self::$supported_list = $get_supported_list; |
| 271 | 271 | return self::$supported_list; |
| 272 | 272 | } |
| 273 | 273 | $get_supported_list = array(); |
| 274 | - $db_classes_path = _XE_PATH_ . "classes/db/"; |
|
| 274 | + $db_classes_path = _XE_PATH_."classes/db/"; |
|
| 275 | 275 | $filter = "/^DB([^\.]+)\.class\.php/i"; |
| 276 | 276 | $supported_list = FileHandler::readDir($db_classes_path, $filter, TRUE); |
| 277 | 277 | |
| 278 | 278 | // after creating instance of class, check is supported |
| 279 | - for($i = 0; $i < count($supported_list); $i++) |
|
| 279 | + for ($i = 0; $i < count($supported_list); $i++) |
|
| 280 | 280 | { |
| 281 | 281 | $db_type = $supported_list[$i]; |
| 282 | 282 | |
| 283 | 283 | $class_name = sprintf("DB%s%s", strtoupper(substr($db_type, 0, 1)), strtolower(substr($db_type, 1))); |
| 284 | - $class_file = sprintf(_XE_PATH_ . "classes/db/%s.class.php", $class_name); |
|
| 285 | - if(!file_exists($class_file)) |
|
| 284 | + $class_file = sprintf(_XE_PATH_."classes/db/%s.class.php", $class_name); |
|
| 285 | + if (!file_exists($class_file)) |
|
| 286 | 286 | { |
| 287 | 287 | continue; |
| 288 | 288 | } |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | require_once($class_file); |
| 292 | 292 | $oDB = new $class_name(); |
| 293 | 293 | |
| 294 | - if(!$oDB) |
|
| 294 | + if (!$oDB) |
|
| 295 | 295 | { |
| 296 | 296 | continue; |
| 297 | 297 | } |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | */ |
| 316 | 316 | function _sortDBMS($a, $b) |
| 317 | 317 | { |
| 318 | - if(!isset($this->priority_dbms[$a->db_type])) |
|
| 318 | + if (!isset($this->priority_dbms[$a->db_type])) |
|
| 319 | 319 | { |
| 320 | 320 | $priority_a = 0; |
| 321 | 321 | } |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | $priority_a = $this->priority_dbms[$a->db_type]; |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - if(!isset($this->priority_dbms[$b->db_type])) |
|
| 327 | + if (!isset($this->priority_dbms[$b->db_type])) |
|
| 328 | 328 | { |
| 329 | 329 | $priority_b = 0; |
| 330 | 330 | } |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | $priority_b = $this->priority_dbms[$b->db_type]; |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | - if($priority_a == $priority_b) |
|
| 336 | + if ($priority_a == $priority_b) |
|
| 337 | 337 | { |
| 338 | 338 | return 0; |
| 339 | 339 | } |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | */ |
| 360 | 360 | function isConnected($type = 'master', $indx = 0) |
| 361 | 361 | { |
| 362 | - if($type == 'master') |
|
| 362 | + if ($type == 'master') |
|
| 363 | 363 | { |
| 364 | 364 | return $this->master_db["is_connected"] ? TRUE : FALSE; |
| 365 | 365 | } |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | */ |
| 389 | 389 | function actFinish() |
| 390 | 390 | { |
| 391 | - if(!$this->query) |
|
| 391 | + if (!$this->query) |
|
| 392 | 392 | { |
| 393 | 393 | return; |
| 394 | 394 | } |
@@ -409,14 +409,14 @@ discard block |
||
| 409 | 409 | |
| 410 | 410 | $bt = version_compare(PHP_VERSION, '5.3.6', '>=') ? debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) : debug_backtrace(); |
| 411 | 411 | |
| 412 | - foreach($bt as $no => $call) |
|
| 412 | + foreach ($bt as $no => $call) |
|
| 413 | 413 | { |
| 414 | - if($call['function'] == 'executeQuery' || $call['function'] == 'executeQueryArray') |
|
| 414 | + if ($call['function'] == 'executeQuery' || $call['function'] == 'executeQueryArray') |
|
| 415 | 415 | { |
| 416 | 416 | $call_no = $no; |
| 417 | 417 | $call_no++; |
| 418 | 418 | $log['called_file'] = $bt[$call_no]['file'].':'.$bt[$call_no]['line']; |
| 419 | - $log['called_file'] = str_replace(_XE_PATH_ , '', $log['called_file']); |
|
| 419 | + $log['called_file'] = str_replace(_XE_PATH_, '', $log['called_file']); |
|
| 420 | 420 | $call_no++; |
| 421 | 421 | $log['called_method'] = $bt[$call_no]['class'].$bt[$call_no]['type'].$bt[$call_no]['function']; |
| 422 | 422 | break; |
@@ -424,22 +424,22 @@ discard block |
||
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | // leave error log if an error occured (if __DEBUG_DB_OUTPUT__ is defined) |
| 427 | - if($this->isError()) |
|
| 427 | + if ($this->isError()) |
|
| 428 | 428 | { |
| 429 | 429 | $log['result'] = 'Failed'; |
| 430 | 430 | $log['errno'] = $this->errno; |
| 431 | 431 | $log['errstr'] = $this->errstr; |
| 432 | 432 | |
| 433 | - if(__DEBUG_DB_OUTPUT__ == 1) |
|
| 433 | + if (__DEBUG_DB_OUTPUT__ == 1) |
|
| 434 | 434 | { |
| 435 | - $debug_file = _XE_PATH_ . "files/_debug_db_query.php"; |
|
| 435 | + $debug_file = _XE_PATH_."files/_debug_db_query.php"; |
|
| 436 | 436 | $buff = array(); |
| 437 | - if(!file_exists($debug_file)) |
|
| 437 | + if (!file_exists($debug_file)) |
|
| 438 | 438 | { |
| 439 | - $buff[] = '<?php exit(); ?' . '>'; |
|
| 439 | + $buff[] = '<?php exit(); ?'.'>'; |
|
| 440 | 440 | } |
| 441 | 441 | $buff[] = print_r($log, TRUE); |
| 442 | - @file_put_contents($log_file, implode("\n", $buff) . "\n\n", FILE_APPEND|LOCK_EX); |
|
| 442 | + @file_put_contents($log_file, implode("\n", $buff)."\n\n", FILE_APPEND | LOCK_EX); |
|
| 443 | 443 | } |
| 444 | 444 | } |
| 445 | 445 | else |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | $log_args = new stdClass; |
| 453 | 453 | $log_args->query = $this->query; |
| 454 | 454 | $log_args->query_id = $this->query_id; |
| 455 | - $log_args->caller = $log['called_method'] . '() in ' . $log['called_file']; |
|
| 455 | + $log_args->caller = $log['called_method'].'() in '.$log['called_file']; |
|
| 456 | 456 | $log_args->connection = $log['connection']; |
| 457 | 457 | writeSlowlog('query', $elapsed_time, $log_args); |
| 458 | 458 | } |
@@ -510,11 +510,11 @@ discard block |
||
| 510 | 510 | { |
| 511 | 511 | static $cache_file = array(); |
| 512 | 512 | |
| 513 | - if(!$query_id) |
|
| 513 | + if (!$query_id) |
|
| 514 | 514 | { |
| 515 | 515 | return new Object(-1, 'msg_invalid_queryid'); |
| 516 | 516 | } |
| 517 | - if(!$this->db_type) |
|
| 517 | + if (!$this->db_type) |
|
| 518 | 518 | { |
| 519 | 519 | return; |
| 520 | 520 | } |
@@ -523,20 +523,20 @@ discard block |
||
| 523 | 523 | |
| 524 | 524 | $this->query_id = $query_id; |
| 525 | 525 | |
| 526 | - if(!isset($cache_file[$query_id]) || !file_exists($cache_file[$query_id])) |
|
| 526 | + if (!isset($cache_file[$query_id]) || !file_exists($cache_file[$query_id])) |
|
| 527 | 527 | { |
| 528 | 528 | $id_args = explode('.', $query_id); |
| 529 | - if(count($id_args) == 2) |
|
| 529 | + if (count($id_args) == 2) |
|
| 530 | 530 | { |
| 531 | 531 | $target = 'modules'; |
| 532 | 532 | $module = $id_args[0]; |
| 533 | 533 | $id = $id_args[1]; |
| 534 | 534 | } |
| 535 | - elseif(count($id_args) == 3) |
|
| 535 | + elseif (count($id_args) == 3) |
|
| 536 | 536 | { |
| 537 | 537 | $target = $id_args[0]; |
| 538 | 538 | $typeList = array('addons' => 1, 'widgets' => 1); |
| 539 | - if(!isset($typeList[$target])) |
|
| 539 | + if (!isset($typeList[$target])) |
|
| 540 | 540 | { |
| 541 | 541 | $this->actDBClassFinish(); |
| 542 | 542 | return; |
@@ -544,14 +544,14 @@ discard block |
||
| 544 | 544 | $module = $id_args[1]; |
| 545 | 545 | $id = $id_args[2]; |
| 546 | 546 | } |
| 547 | - if(!$target || !$module || !$id) |
|
| 547 | + if (!$target || !$module || !$id) |
|
| 548 | 548 | { |
| 549 | 549 | $this->actDBClassFinish(); |
| 550 | 550 | return new Object(-1, 'msg_invalid_queryid'); |
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | $xml_file = sprintf('%s%s/%s/queries/%s.xml', _XE_PATH_, $target, $module, $id); |
| 554 | - if(!file_exists($xml_file)) |
|
| 554 | + if (!file_exists($xml_file)) |
|
| 555 | 555 | { |
| 556 | 556 | $this->actDBClassFinish(); |
| 557 | 557 | return new Object(-1, 'msg_invalid_queryid'); |
@@ -579,13 +579,13 @@ discard block |
||
| 579 | 579 | $cache_file = sprintf('%s%s%s.%s.%s.cache.php', _XE_PATH_, $this->cache_file, $query_id, __ZBXE_VERSION__, $this->db_type); |
| 580 | 580 | |
| 581 | 581 | $cache_time = -1; |
| 582 | - if(file_exists($cache_file)) |
|
| 582 | + if (file_exists($cache_file)) |
|
| 583 | 583 | { |
| 584 | 584 | $cache_time = filemtime($cache_file); |
| 585 | 585 | } |
| 586 | 586 | |
| 587 | 587 | // if there is no cache file or is not new, find original xml query file and parse it |
| 588 | - 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')) |
|
| 588 | + 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')) |
|
| 589 | 589 | { |
| 590 | 590 | $oParser = new XmlQueryParser(); |
| 591 | 591 | $oParser->parse($query_id, $xml_file, $cache_file); |
@@ -606,27 +606,27 @@ discard block |
||
| 606 | 606 | { |
| 607 | 607 | global $lang; |
| 608 | 608 | |
| 609 | - if(!in_array($type, array('master','slave'))) $type = 'slave'; |
|
| 609 | + if (!in_array($type, array('master', 'slave'))) $type = 'slave'; |
|
| 610 | 610 | |
| 611 | - if(!file_exists($cache_file)) |
|
| 611 | + if (!file_exists($cache_file)) |
|
| 612 | 612 | { |
| 613 | 613 | return new Object(-1, 'msg_invalid_queryid'); |
| 614 | 614 | } |
| 615 | 615 | |
| 616 | - if($source_args) |
|
| 616 | + if ($source_args) |
|
| 617 | 617 | { |
| 618 | 618 | $args = clone $source_args; |
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | $output = include($cache_file); |
| 622 | 622 | |
| 623 | - if((is_a($output, 'Object') || is_subclass_of($output, 'Object')) && !$output->toBool()) |
|
| 623 | + if ((is_a($output, 'Object') || is_subclass_of($output, 'Object')) && !$output->toBool()) |
|
| 624 | 624 | { |
| 625 | 625 | return $output; |
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | // execute appropriate query |
| 629 | - switch($output->getAction()) |
|
| 629 | + switch ($output->getAction()) |
|
| 630 | 630 | { |
| 631 | 631 | case 'insert' : |
| 632 | 632 | case 'insert-select' : |
@@ -649,11 +649,11 @@ discard block |
||
| 649 | 649 | break; |
| 650 | 650 | } |
| 651 | 651 | |
| 652 | - if($this->isError()) |
|
| 652 | + if ($this->isError()) |
|
| 653 | 653 | { |
| 654 | 654 | $output = $this->getError(); |
| 655 | 655 | } |
| 656 | - else if(!is_a($output, 'Object') && !is_subclass_of($output, 'Object')) |
|
| 656 | + else if (!is_a($output, 'Object') && !is_subclass_of($output, 'Object')) |
|
| 657 | 657 | { |
| 658 | 658 | $output = new Object(); |
| 659 | 659 | } |
@@ -799,7 +799,7 @@ discard block |
||
| 799 | 799 | */ |
| 800 | 800 | function dropTable($table_name) |
| 801 | 801 | { |
| 802 | - if(!$table_name) |
|
| 802 | + if (!$table_name) |
|
| 803 | 803 | { |
| 804 | 804 | return; |
| 805 | 805 | } |
@@ -816,59 +816,59 @@ discard block |
||
| 816 | 816 | function getSelectSql($query, $with_values = TRUE) |
| 817 | 817 | { |
| 818 | 818 | $select = $query->getSelectString($with_values); |
| 819 | - if($select == '') |
|
| 819 | + if ($select == '') |
|
| 820 | 820 | { |
| 821 | 821 | return new Object(-1, "Invalid query"); |
| 822 | 822 | } |
| 823 | - $select = 'SELECT ' . $select; |
|
| 823 | + $select = 'SELECT '.$select; |
|
| 824 | 824 | |
| 825 | 825 | $from = $query->getFromString($with_values); |
| 826 | - if($from == '') |
|
| 826 | + if ($from == '') |
|
| 827 | 827 | { |
| 828 | 828 | return new Object(-1, "Invalid query"); |
| 829 | 829 | } |
| 830 | - $from = ' FROM ' . $from; |
|
| 830 | + $from = ' FROM '.$from; |
|
| 831 | 831 | |
| 832 | 832 | $where = $query->getWhereString($with_values); |
| 833 | - if($where != '') |
|
| 833 | + if ($where != '') |
|
| 834 | 834 | { |
| 835 | - $where = ' WHERE ' . $where; |
|
| 835 | + $where = ' WHERE '.$where; |
|
| 836 | 836 | } |
| 837 | 837 | |
| 838 | 838 | $tableObjects = $query->getTables(); |
| 839 | 839 | $index_hint_list = ''; |
| 840 | - foreach($tableObjects as $tableObject) |
|
| 840 | + foreach ($tableObjects as $tableObject) |
|
| 841 | 841 | { |
| 842 | - if(is_a($tableObject, 'CubridTableWithHint')) |
|
| 842 | + if (is_a($tableObject, 'CubridTableWithHint')) |
|
| 843 | 843 | { |
| 844 | - $index_hint_list .= $tableObject->getIndexHintString() . ', '; |
|
| 844 | + $index_hint_list .= $tableObject->getIndexHintString().', '; |
|
| 845 | 845 | } |
| 846 | 846 | } |
| 847 | 847 | $index_hint_list = substr($index_hint_list, 0, -2); |
| 848 | - if($index_hint_list != '') |
|
| 848 | + if ($index_hint_list != '') |
|
| 849 | 849 | { |
| 850 | - $index_hint_list = 'USING INDEX ' . $index_hint_list; |
|
| 850 | + $index_hint_list = 'USING INDEX '.$index_hint_list; |
|
| 851 | 851 | } |
| 852 | 852 | |
| 853 | 853 | $groupBy = $query->getGroupByString(); |
| 854 | - if($groupBy != '') |
|
| 854 | + if ($groupBy != '') |
|
| 855 | 855 | { |
| 856 | - $groupBy = ' GROUP BY ' . $groupBy; |
|
| 856 | + $groupBy = ' GROUP BY '.$groupBy; |
|
| 857 | 857 | } |
| 858 | 858 | |
| 859 | 859 | $orderBy = $query->getOrderByString(); |
| 860 | - if($orderBy != '') |
|
| 860 | + if ($orderBy != '') |
|
| 861 | 861 | { |
| 862 | - $orderBy = ' ORDER BY ' . $orderBy; |
|
| 862 | + $orderBy = ' ORDER BY '.$orderBy; |
|
| 863 | 863 | } |
| 864 | 864 | |
| 865 | 865 | $limit = $query->getLimitString(); |
| 866 | - if($limit != '') |
|
| 866 | + if ($limit != '') |
|
| 867 | 867 | { |
| 868 | - $limit = ' LIMIT ' . $limit; |
|
| 868 | + $limit = ' LIMIT '.$limit; |
|
| 869 | 869 | } |
| 870 | 870 | |
| 871 | - return $select . ' ' . $from . ' ' . $where . ' ' . $index_hint_list . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit; |
|
| 871 | + return $select.' '.$from.' '.$where.' '.$index_hint_list.' '.$groupBy.' '.$orderBy.' '.$limit; |
|
| 872 | 872 | } |
| 873 | 873 | |
| 874 | 874 | /** |
@@ -886,7 +886,7 @@ discard block |
||
| 886 | 886 | { |
| 887 | 887 | $new_update_columns = array(); |
| 888 | 888 | $click_count_columns = $queryObject->getClickCountColumns(); |
| 889 | - foreach($click_count_columns as $click_count_column) |
|
| 889 | + foreach ($click_count_columns as $click_count_column) |
|
| 890 | 890 | { |
| 891 | 891 | $click_count_column_name = $click_count_column->column_name; |
| 892 | 892 | |
@@ -918,16 +918,16 @@ discard block |
||
| 918 | 918 | $sql .= $tables[0]->getAlias(); |
| 919 | 919 | |
| 920 | 920 | $from = $query->getFromString($with_values); |
| 921 | - if($from == '') |
|
| 921 | + if ($from == '') |
|
| 922 | 922 | { |
| 923 | 923 | return new Object(-1, "Invalid query"); |
| 924 | 924 | } |
| 925 | - $sql .= ' FROM ' . $from; |
|
| 925 | + $sql .= ' FROM '.$from; |
|
| 926 | 926 | |
| 927 | 927 | $where = $query->getWhereString($with_values); |
| 928 | - if($where != '') |
|
| 928 | + if ($where != '') |
|
| 929 | 929 | { |
| 930 | - $sql .= ' WHERE ' . $where; |
|
| 930 | + $sql .= ' WHERE '.$where; |
|
| 931 | 931 | } |
| 932 | 932 | |
| 933 | 933 | return $sql; |
@@ -943,26 +943,26 @@ discard block |
||
| 943 | 943 | function getUpdateSql($query, $with_values = TRUE, $with_priority = FALSE) |
| 944 | 944 | { |
| 945 | 945 | $columnsList = $query->getUpdateString($with_values); |
| 946 | - if($columnsList == '') |
|
| 946 | + if ($columnsList == '') |
|
| 947 | 947 | { |
| 948 | 948 | return new Object(-1, "Invalid query"); |
| 949 | 949 | } |
| 950 | 950 | |
| 951 | 951 | $tables = $query->getFromString($with_values); |
| 952 | - if($tables == '') |
|
| 952 | + if ($tables == '') |
|
| 953 | 953 | { |
| 954 | 954 | return new Object(-1, "Invalid query"); |
| 955 | 955 | } |
| 956 | 956 | |
| 957 | 957 | $where = $query->getWhereString($with_values); |
| 958 | - if($where != '') |
|
| 958 | + if ($where != '') |
|
| 959 | 959 | { |
| 960 | - $where = ' WHERE ' . $where; |
|
| 960 | + $where = ' WHERE '.$where; |
|
| 961 | 961 | } |
| 962 | 962 | |
| 963 | 963 | $priority = $with_priority ? $query->getPriority() : ''; |
| 964 | 964 | |
| 965 | - return "UPDATE $priority $tables SET $columnsList " . $where; |
|
| 965 | + return "UPDATE $priority $tables SET $columnsList ".$where; |
|
| 966 | 966 | } |
| 967 | 967 | |
| 968 | 968 | /** |
@@ -1000,27 +1000,27 @@ discard block |
||
| 1000 | 1000 | */ |
| 1001 | 1001 | function _getConnection($type = 'master', $indx = NULL) |
| 1002 | 1002 | { |
| 1003 | - if($type == 'master') |
|
| 1003 | + if ($type == 'master') |
|
| 1004 | 1004 | { |
| 1005 | - if(!$this->master_db['is_connected']) |
|
| 1005 | + if (!$this->master_db['is_connected']) |
|
| 1006 | 1006 | { |
| 1007 | 1007 | $this->_connect($type); |
| 1008 | 1008 | } |
| 1009 | - $this->connection = 'Master ' . $this->master_db['db_hostname']; |
|
| 1009 | + $this->connection = 'Master '.$this->master_db['db_hostname']; |
|
| 1010 | 1010 | return $this->master_db["resource"]; |
| 1011 | 1011 | } |
| 1012 | 1012 | |
| 1013 | - if($indx === NULL) |
|
| 1013 | + if ($indx === NULL) |
|
| 1014 | 1014 | { |
| 1015 | 1015 | $indx = $this->_getSlaveConnectionStringIndex($type); |
| 1016 | 1016 | } |
| 1017 | 1017 | |
| 1018 | - if(!$this->slave_db[$indx]['is_connected']) |
|
| 1018 | + if (!$this->slave_db[$indx]['is_connected']) |
|
| 1019 | 1019 | { |
| 1020 | 1020 | $this->_connect($type, $indx); |
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | - $this->connection = 'Slave ' . $this->slave_db[$indx]['db_hostname']; |
|
| 1023 | + $this->connection = 'Slave '.$this->slave_db[$indx]['db_hostname']; |
|
| 1024 | 1024 | return $this->slave_db[$indx]["resource"]; |
| 1025 | 1025 | } |
| 1026 | 1026 | |
@@ -1030,11 +1030,11 @@ discard block |
||
| 1030 | 1030 | */ |
| 1031 | 1031 | function _dbInfoExists() |
| 1032 | 1032 | { |
| 1033 | - if(!$this->master_db) |
|
| 1033 | + if (!$this->master_db) |
|
| 1034 | 1034 | { |
| 1035 | 1035 | return FALSE; |
| 1036 | 1036 | } |
| 1037 | - if(count($this->slave_db) === 0) |
|
| 1037 | + if (count($this->slave_db) === 0) |
|
| 1038 | 1038 | { |
| 1039 | 1039 | return FALSE; |
| 1040 | 1040 | } |
@@ -1060,12 +1060,12 @@ discard block |
||
| 1060 | 1060 | */ |
| 1061 | 1061 | function close($type = 'master', $indx = 0) |
| 1062 | 1062 | { |
| 1063 | - if(!$this->isConnected($type, $indx)) |
|
| 1063 | + if (!$this->isConnected($type, $indx)) |
|
| 1064 | 1064 | { |
| 1065 | 1065 | return; |
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 1068 | - if($type == 'master') |
|
| 1068 | + if ($type == 'master') |
|
| 1069 | 1069 | { |
| 1070 | 1070 | $connection = &$this->master_db; |
| 1071 | 1071 | } |
@@ -1096,12 +1096,12 @@ discard block |
||
| 1096 | 1096 | */ |
| 1097 | 1097 | function begin() |
| 1098 | 1098 | { |
| 1099 | - if(!$this->isConnected()) |
|
| 1099 | + if (!$this->isConnected()) |
|
| 1100 | 1100 | { |
| 1101 | 1101 | return; |
| 1102 | 1102 | } |
| 1103 | 1103 | |
| 1104 | - if($this->_begin($this->transactionNestedLevel)) |
|
| 1104 | + if ($this->_begin($this->transactionNestedLevel)) |
|
| 1105 | 1105 | { |
| 1106 | 1106 | $this->transaction_started = TRUE; |
| 1107 | 1107 | $this->transactionNestedLevel++; |
@@ -1124,15 +1124,15 @@ discard block |
||
| 1124 | 1124 | */ |
| 1125 | 1125 | function rollback() |
| 1126 | 1126 | { |
| 1127 | - if(!$this->isConnected() || !$this->transaction_started) |
|
| 1127 | + if (!$this->isConnected() || !$this->transaction_started) |
|
| 1128 | 1128 | { |
| 1129 | 1129 | return; |
| 1130 | 1130 | } |
| 1131 | - if($this->_rollback($this->transactionNestedLevel)) |
|
| 1131 | + if ($this->_rollback($this->transactionNestedLevel)) |
|
| 1132 | 1132 | { |
| 1133 | 1133 | $this->transactionNestedLevel--; |
| 1134 | 1134 | |
| 1135 | - if(!$this->transactionNestedLevel) |
|
| 1135 | + if (!$this->transactionNestedLevel) |
|
| 1136 | 1136 | { |
| 1137 | 1137 | $this->transaction_started = FALSE; |
| 1138 | 1138 | } |
@@ -1156,11 +1156,11 @@ discard block |
||
| 1156 | 1156 | */ |
| 1157 | 1157 | function commit($force = FALSE) |
| 1158 | 1158 | { |
| 1159 | - if(!$force && (!$this->isConnected() || !$this->transaction_started)) |
|
| 1159 | + if (!$force && (!$this->isConnected() || !$this->transaction_started)) |
|
| 1160 | 1160 | { |
| 1161 | 1161 | return; |
| 1162 | 1162 | } |
| 1163 | - if($this->transactionNestedLevel == 1 && $this->_commit()) |
|
| 1163 | + if ($this->transactionNestedLevel == 1 && $this->_commit()) |
|
| 1164 | 1164 | { |
| 1165 | 1165 | $this->transaction_started = FALSE; |
| 1166 | 1166 | $this->transactionNestedLevel = 0; |
@@ -1192,7 +1192,7 @@ discard block |
||
| 1192 | 1192 | */ |
| 1193 | 1193 | function _query($query, $connection = NULL) |
| 1194 | 1194 | { |
| 1195 | - if($connection == NULL) |
|
| 1195 | + if ($connection == NULL) |
|
| 1196 | 1196 | { |
| 1197 | 1197 | $connection = $this->_getConnection('master'); |
| 1198 | 1198 | } |
@@ -1217,7 +1217,7 @@ discard block |
||
| 1217 | 1217 | { |
| 1218 | 1218 | $db_info = Context::getDBInfo(); |
| 1219 | 1219 | $this->master_db = $db_info->master_db; |
| 1220 | - if($db_info->master_db["db_hostname"] == $db_info->slave_db[0]["db_hostname"] |
|
| 1220 | + if ($db_info->master_db["db_hostname"] == $db_info->slave_db[0]["db_hostname"] |
|
| 1221 | 1221 | && $db_info->master_db["db_port"] == $db_info->slave_db[0]["db_port"] |
| 1222 | 1222 | && $db_info->master_db["db_userid"] == $db_info->slave_db[0]["db_userid"] |
| 1223 | 1223 | && $db_info->master_db["db_password"] == $db_info->slave_db[0]["db_password"] |
@@ -1265,18 +1265,18 @@ discard block |
||
| 1265 | 1265 | */ |
| 1266 | 1266 | function _connect($type = 'master', $indx = 0) |
| 1267 | 1267 | { |
| 1268 | - if($this->isConnected($type, $indx)) |
|
| 1268 | + if ($this->isConnected($type, $indx)) |
|
| 1269 | 1269 | { |
| 1270 | 1270 | return; |
| 1271 | 1271 | } |
| 1272 | 1272 | |
| 1273 | 1273 | // Ignore if no DB information exists |
| 1274 | - if(!$this->_dbInfoExists()) |
|
| 1274 | + if (!$this->_dbInfoExists()) |
|
| 1275 | 1275 | { |
| 1276 | 1276 | return; |
| 1277 | 1277 | } |
| 1278 | 1278 | |
| 1279 | - if($type == 'master') |
|
| 1279 | + if ($type == 'master') |
|
| 1280 | 1280 | { |
| 1281 | 1281 | $connection = &$this->master_db; |
| 1282 | 1282 | } |
@@ -1286,7 +1286,7 @@ discard block |
||
| 1286 | 1286 | } |
| 1287 | 1287 | |
| 1288 | 1288 | $result = $this->__connect($connection); |
| 1289 | - if($result === NULL || $result === FALSE) |
|
| 1289 | + if ($result === NULL || $result === FALSE) |
|
| 1290 | 1290 | { |
| 1291 | 1291 | $connection["is_connected"] = FALSE; |
| 1292 | 1292 | return; |
@@ -1297,7 +1297,7 @@ discard block |
||
| 1297 | 1297 | $connection["is_connected"] = TRUE; |
| 1298 | 1298 | |
| 1299 | 1299 | // Save connection info for db logs |
| 1300 | - $this->connection = ucfirst($type) . ' ' . $connection["db_hostname"]; |
|
| 1300 | + $this->connection = ucfirst($type).' '.$connection["db_hostname"]; |
|
| 1301 | 1301 | |
| 1302 | 1302 | // regist $this->close callback |
| 1303 | 1303 | register_shutdown_function(array($this, "close")); |
@@ -1322,7 +1322,7 @@ discard block |
||
| 1322 | 1322 | */ |
| 1323 | 1323 | function actDBClassFinish() |
| 1324 | 1324 | { |
| 1325 | - if(!$this->query) |
|
| 1325 | + if (!$this->query) |
|
| 1326 | 1326 | { |
| 1327 | 1327 | return; |
| 1328 | 1328 | } |
@@ -1345,7 +1345,7 @@ discard block |
||
| 1345 | 1345 | function getParser($force = FALSE) |
| 1346 | 1346 | { |
| 1347 | 1347 | static $dbParser = NULL; |
| 1348 | - if(!$dbParser || $force) |
|
| 1348 | + if (!$dbParser || $force) |
|
| 1349 | 1349 | { |
| 1350 | 1350 | $oDB = DB::getInstance(); |
| 1351 | 1351 | $dbParser = $oDB->getParser(); |