@@ -46,17 +46,17 @@ |
||
| 46 | 46 | |
| 47 | 47 | $index_hint_string = ''; |
| 48 | 48 | $indexTypeList = array('USE' => 1, 'FORCE' => 1); |
| 49 | - foreach($this->index_hints_list as $index_hint) |
|
| 49 | + foreach ($this->index_hints_list as $index_hint) |
|
| 50 | 50 | { |
| 51 | 51 | $index_hint_type = $index_hint->getIndexHintType(); |
| 52 | - if(isset($indexTypeList[$index_hint_type])) |
|
| 52 | + if (isset($indexTypeList[$index_hint_type])) |
|
| 53 | 53 | { |
| 54 | - $index_hint_string .= 'INDEX(' . $index_hint->getIndexName() . '), '; |
|
| 54 | + $index_hint_string .= 'INDEX('.$index_hint->getIndexName().'), '; |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | - if($index_hint_string != '') |
|
| 57 | + if ($index_hint_string != '') |
|
| 58 | 58 | { |
| 59 | - $result .= ' WITH(' . substr($index_hint_string, 0, -2) . ') '; |
|
| 59 | + $result .= ' WITH('.substr($index_hint_string, 0, -2).') '; |
|
| 60 | 60 | } |
| 61 | 61 | return $result; |
| 62 | 62 | } |
@@ -47,33 +47,33 @@ |
||
| 47 | 47 | $use_index_hint = ''; |
| 48 | 48 | $force_index_hint = ''; |
| 49 | 49 | $ignore_index_hint = ''; |
| 50 | - foreach($this->index_hints_list as $index_hint) |
|
| 50 | + foreach ($this->index_hints_list as $index_hint) |
|
| 51 | 51 | { |
| 52 | 52 | $index_hint_type = $index_hint->getIndexHintType(); |
| 53 | - if($index_hint_type == 'USE') |
|
| 53 | + if ($index_hint_type == 'USE') |
|
| 54 | 54 | { |
| 55 | - $use_index_hint .= $index_hint->getIndexName() . ', '; |
|
| 55 | + $use_index_hint .= $index_hint->getIndexName().', '; |
|
| 56 | 56 | } |
| 57 | - else if($index_hint_type == 'FORCE') |
|
| 57 | + else if ($index_hint_type == 'FORCE') |
|
| 58 | 58 | { |
| 59 | - $force_index_hint .= $index_hint->getIndexName() . ', '; |
|
| 59 | + $force_index_hint .= $index_hint->getIndexName().', '; |
|
| 60 | 60 | } |
| 61 | - else if($index_hint_type == 'IGNORE') |
|
| 61 | + else if ($index_hint_type == 'IGNORE') |
|
| 62 | 62 | { |
| 63 | - $ignore_index_hint .= $index_hint->getIndexName() . ', '; |
|
| 63 | + $ignore_index_hint .= $index_hint->getIndexName().', '; |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | - if($use_index_hint != '') |
|
| 66 | + if ($use_index_hint != '') |
|
| 67 | 67 | { |
| 68 | - $result .= ' USE INDEX (' . substr($use_index_hint, 0, -2) . ') '; |
|
| 68 | + $result .= ' USE INDEX ('.substr($use_index_hint, 0, -2).') '; |
|
| 69 | 69 | } |
| 70 | - if($force_index_hint != '') |
|
| 70 | + if ($force_index_hint != '') |
|
| 71 | 71 | { |
| 72 | - $result .= ' FORCE INDEX (' . substr($force_index_hint, 0, -2) . ') '; |
|
| 72 | + $result .= ' FORCE INDEX ('.substr($force_index_hint, 0, -2).') '; |
|
| 73 | 73 | } |
| 74 | - if($ignore_index_hint != '') |
|
| 74 | + if ($ignore_index_hint != '') |
|
| 75 | 75 | { |
| 76 | - $result .= ' IGNORE INDEX (' . substr($ignore_index_hint, 0, -2) . ') '; |
|
| 76 | + $result .= ' IGNORE INDEX ('.substr($ignore_index_hint, 0, -2).') '; |
|
| 77 | 77 | } |
| 78 | 78 | return $result; |
| 79 | 79 | } |
@@ -53,12 +53,10 @@ |
||
| 53 | 53 | if($index_hint_type == 'USE') |
| 54 | 54 | { |
| 55 | 55 | $use_index_hint .= $index_hint->getIndexName() . ', '; |
| 56 | - } |
|
| 57 | - else if($index_hint_type == 'FORCE') |
|
| 56 | + } else if($index_hint_type == 'FORCE') |
|
| 58 | 57 | { |
| 59 | 58 | $force_index_hint .= $index_hint->getIndexName() . ', '; |
| 60 | - } |
|
| 61 | - else if($index_hint_type == 'IGNORE') |
|
| 59 | + } else if($index_hint_type == 'IGNORE') |
|
| 62 | 60 | { |
| 63 | 61 | $ignore_index_hint .= $index_hint->getIndexName() . ', '; |
| 64 | 62 | } |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | function toString() |
| 37 | 37 | { |
| 38 | 38 | //return $this->name; |
| 39 | - return sprintf("%s%s", $this->name, $this->alias ? ' as ' . $this->alias : ''); |
|
| 39 | + return sprintf("%s%s", $this->name, $this->alias ? ' as '.$this->alias : ''); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | function getName() |
@@ -41,10 +41,10 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | function toString($with_value = true) |
| 43 | 43 | { |
| 44 | - $part = $this->join_type . ' ' . $this->name; |
|
| 45 | - $part .= $this->alias ? ' as ' . $this->alias : ''; |
|
| 44 | + $part = $this->join_type.' '.$this->name; |
|
| 45 | + $part .= $this->alias ? ' as '.$this->alias : ''; |
|
| 46 | 46 | $part .= ' on '; |
| 47 | - foreach($this->conditions as $conditionGroup) |
|
| 47 | + foreach ($this->conditions as $conditionGroup) |
|
| 48 | 48 | { |
| 49 | 49 | $part .= $conditionGroup->toString($with_value); |
| 50 | 50 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | function getArguments() |
| 60 | 60 | { |
| 61 | 61 | $args = array(); |
| 62 | - foreach($this->conditions as $conditionGroup) |
|
| 62 | + foreach ($this->conditions as $conditionGroup) |
|
| 63 | 63 | { |
| 64 | 64 | $args = array_merge($args, $conditionGroup->getArguments()); |
| 65 | 65 | } |
@@ -59,11 +59,11 @@ |
||
| 59 | 59 | function getArguments() |
| 60 | 60 | { |
| 61 | 61 | $args = array(); |
| 62 | - if(is_a($this->column_name, 'Argument')) |
|
| 62 | + if (is_a($this->column_name, 'Argument')) |
|
| 63 | 63 | { |
| 64 | 64 | $args[] = $this->column_name; |
| 65 | 65 | } |
| 66 | - if(is_a($this->sort_order, 'Argument')) |
|
| 66 | + if (is_a($this->sort_order, 'Argument')) |
|
| 67 | 67 | { |
| 68 | 68 | $args[] = $this->sort_order; |
| 69 | 69 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | function __construct($list_count, $page = NULL, $page_count = NULL, $offset = NULL) |
| 45 | 45 | { |
| 46 | 46 | $this->list_count = $list_count; |
| 47 | - if($page) |
|
| 47 | + if ($page) |
|
| 48 | 48 | { |
| 49 | 49 | $list_count_value = $list_count->getValue(); |
| 50 | 50 | $page_value = $page->getValue(); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | $this->page_count = $page_count; |
| 53 | 53 | $this->page = $page; |
| 54 | 54 | } |
| 55 | - elseif($offset) |
|
| 55 | + elseif ($offset) |
|
| 56 | 56 | { |
| 57 | 57 | $this->start = $offset->getValue(); |
| 58 | 58 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | function isPageHandler() |
| 66 | 66 | { |
| 67 | - if($this->page) |
|
| 67 | + if ($this->page) |
|
| 68 | 68 | { |
| 69 | 69 | return true; |
| 70 | 70 | } |
@@ -86,9 +86,9 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | function toString() |
| 88 | 88 | { |
| 89 | - if($this->page || $this->start) |
|
| 89 | + if ($this->page || $this->start) |
|
| 90 | 90 | { |
| 91 | - return $this->start . ' , ' . $this->list_count->getValue(); |
|
| 91 | + return $this->start.' , '.$this->list_count->getValue(); |
|
| 92 | 92 | } |
| 93 | 93 | else |
| 94 | 94 | { |
@@ -51,8 +51,7 @@ discard block |
||
| 51 | 51 | $this->start = ($page_value - 1) * $list_count_value; |
| 52 | 52 | $this->page_count = $page_count; |
| 53 | 53 | $this->page = $page; |
| 54 | - } |
|
| 55 | - elseif($offset) |
|
| 54 | + } elseif($offset) |
|
| 56 | 55 | { |
| 57 | 56 | $this->start = $offset->getValue(); |
| 58 | 57 | } |
@@ -67,8 +66,7 @@ discard block |
||
| 67 | 66 | if($this->page) |
| 68 | 67 | { |
| 69 | 68 | return true; |
| 70 | - } |
|
| 71 | - else |
|
| 69 | + } else |
|
| 72 | 70 | { |
| 73 | 71 | return false; |
| 74 | 72 | } |
@@ -89,8 +87,7 @@ discard block |
||
| 89 | 87 | if($this->page || $this->start) |
| 90 | 88 | { |
| 91 | 89 | return $this->start . ' , ' . $this->list_count->getValue(); |
| 92 | - } |
|
| 93 | - else |
|
| 90 | + } else |
|
| 94 | 91 | { |
| 95 | 92 | return $this->list_count->getValue(); |
| 96 | 93 | } |
@@ -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 BaseObject(-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 BaseObject(-1, 'msg_db_not_setted'); |
| 164 | 164 | } |
@@ -187,8 +187,8 @@ discard block |
||
| 187 | 187 | */ |
| 188 | 188 | function __construct() |
| 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(FALSE); |
| 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($debug_file, implode("\n", $buff) . "\n\n", FILE_APPEND|LOCK_EX); |
|
| 442 | + @file_put_contents($debug_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 BaseObject(-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 BaseObject(-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 BaseObject(-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 BaseObject(-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, 'BaseObject') || is_subclass_of($output, 'BaseObject')) && !$output->toBool()) |
|
| 623 | + if ((is_a($output, 'BaseObject') || is_subclass_of($output, 'BaseObject')) && !$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, 'BaseObject') && !is_subclass_of($output, 'BaseObject')) |
|
| 656 | + else if (!is_a($output, 'BaseObject') && !is_subclass_of($output, 'BaseObject')) |
|
| 657 | 657 | { |
| 658 | 658 | $output = new BaseObject(); |
| 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 BaseObject(-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 BaseObject(-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 BaseObject(-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 BaseObject(-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 BaseObject(-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(); |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | function __construct($auto_connect = TRUE) |
| 24 | 24 | { |
| 25 | 25 | $this->_setDBInfo(); |
| 26 | - if($auto_connect) $this->_connect(); |
|
| 26 | + if ($auto_connect) $this->_connect(); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -55,13 +55,13 @@ discard block |
||
| 55 | 55 | { |
| 56 | 56 | $connection = $this->_getConnection('master'); |
| 57 | 57 | |
| 58 | - if(!$transactionLevel) |
|
| 58 | + if (!$transactionLevel) |
|
| 59 | 59 | { |
| 60 | 60 | $this->_query("START TRANSACTION", $connection); |
| 61 | 61 | } |
| 62 | 62 | else |
| 63 | 63 | { |
| 64 | - $this->_query("SAVEPOINT SP" . $transactionLevel, $connection); |
|
| 64 | + $this->_query("SAVEPOINT SP".$transactionLevel, $connection); |
|
| 65 | 65 | } |
| 66 | 66 | return true; |
| 67 | 67 | } |
@@ -77,9 +77,9 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | $point = $transactionLevel - 1; |
| 79 | 79 | |
| 80 | - if($point) |
|
| 80 | + if ($point) |
|
| 81 | 81 | { |
| 82 | - $this->_query("ROLLBACK TO SP" . $point, $connection); |
|
| 82 | + $this->_query("ROLLBACK TO SP".$point, $connection); |
|
| 83 | 83 | } |
| 84 | 84 | else |
| 85 | 85 | { |
@@ -109,14 +109,14 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | function __query($query, $connection) |
| 111 | 111 | { |
| 112 | - if(!$connection) |
|
| 112 | + if (!$connection) |
|
| 113 | 113 | { |
| 114 | 114 | exit('XE cannot handle DB connection.'); |
| 115 | 115 | } |
| 116 | 116 | // Run the query statement |
| 117 | 117 | $result = @mysql_query($query, $connection); |
| 118 | 118 | // Error Check |
| 119 | - if(mysql_error($connection)) |
|
| 119 | + if (mysql_error($connection)) |
|
| 120 | 120 | { |
| 121 | 121 | $this->setError(mysql_errno($connection), mysql_error($connection)); |
| 122 | 122 | } |
@@ -140,13 +140,13 @@ discard block |
||
| 140 | 140 | $xml_obj = $oXml->parse($xml_doc); |
| 141 | 141 | // Create a table schema |
| 142 | 142 | $table_name = $xml_obj->table->attrs->name; |
| 143 | - if($this->isTableExists($table_name)) |
|
| 143 | + if ($this->isTableExists($table_name)) |
|
| 144 | 144 | { |
| 145 | 145 | return; |
| 146 | 146 | } |
| 147 | - $table_name = $this->prefix . $table_name; |
|
| 147 | + $table_name = $this->prefix.$table_name; |
|
| 148 | 148 | |
| 149 | - if(!is_array($xml_obj->table->column)) |
|
| 149 | + if (!is_array($xml_obj->table->column)) |
|
| 150 | 150 | { |
| 151 | 151 | $columns[] = $xml_obj->table->column; |
| 152 | 152 | } |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | $columns = $xml_obj->table->column; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - foreach($columns as $column) |
|
| 158 | + foreach ($columns as $column) |
|
| 159 | 159 | { |
| 160 | 160 | $name = $column->attrs->name; |
| 161 | 161 | $type = $column->attrs->type; |
@@ -167,47 +167,47 @@ discard block |
||
| 167 | 167 | $default = $column->attrs->default; |
| 168 | 168 | $auto_increment = $column->attrs->auto_increment; |
| 169 | 169 | |
| 170 | - $column_schema[] = sprintf('`%s` %s%s %s %s %s', $name, $this->column_type[$type], $size ? '(' . $size . ')' : '', isset($default) ? "default '" . $default . "'" : '', $notnull ? 'not null' : '', $auto_increment ? 'auto_increment' : ''); |
|
| 170 | + $column_schema[] = sprintf('`%s` %s%s %s %s %s', $name, $this->column_type[$type], $size ? '('.$size.')' : '', isset($default) ? "default '".$default."'" : '', $notnull ? 'not null' : '', $auto_increment ? 'auto_increment' : ''); |
|
| 171 | 171 | |
| 172 | - if($primary_key) |
|
| 172 | + if ($primary_key) |
|
| 173 | 173 | { |
| 174 | 174 | $primary_list[] = $name; |
| 175 | 175 | } |
| 176 | - else if($unique) |
|
| 176 | + else if ($unique) |
|
| 177 | 177 | { |
| 178 | 178 | $unique_list[$unique][] = $name; |
| 179 | 179 | } |
| 180 | - else if($index) |
|
| 180 | + else if ($index) |
|
| 181 | 181 | { |
| 182 | 182 | $index_list[$index][] = $name; |
| 183 | 183 | } |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - if(count($primary_list)) |
|
| 186 | + if (count($primary_list)) |
|
| 187 | 187 | { |
| 188 | - $column_schema[] = sprintf("primary key (%s)", '`' . implode($primary_list, '`,`') . '`'); |
|
| 188 | + $column_schema[] = sprintf("primary key (%s)", '`'.implode($primary_list, '`,`').'`'); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - if(count($unique_list)) |
|
| 191 | + if (count($unique_list)) |
|
| 192 | 192 | { |
| 193 | - foreach($unique_list as $key => $val) |
|
| 193 | + foreach ($unique_list as $key => $val) |
|
| 194 | 194 | { |
| 195 | - $column_schema[] = sprintf("unique %s (%s)", $key, '`' . implode($val, '`,`') . '`'); |
|
| 195 | + $column_schema[] = sprintf("unique %s (%s)", $key, '`'.implode($val, '`,`').'`'); |
|
| 196 | 196 | } |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - if(count($index_list)) |
|
| 199 | + if (count($index_list)) |
|
| 200 | 200 | { |
| 201 | - foreach($index_list as $key => $val) |
|
| 201 | + foreach ($index_list as $key => $val) |
|
| 202 | 202 | { |
| 203 | - $column_schema[] = sprintf("index %s (%s)", $key, '`' . implode($val, '`,`') . '`'); |
|
| 203 | + $column_schema[] = sprintf("index %s (%s)", $key, '`'.implode($val, '`,`').'`'); |
|
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | $schema = sprintf('create table `%s` (%s%s) %s;', $this->addQuotes($table_name), "\n", implode($column_schema, ",\n"), "ENGINE = INNODB CHARACTER SET utf8 COLLATE utf8_general_ci"); |
| 208 | 208 | |
| 209 | 209 | $output = $this->_query($schema); |
| 210 | - if(!$output) |
|
| 210 | + if (!$output) |
|
| 211 | 211 | { |
| 212 | 212 | return false; |
| 213 | 213 | } |
@@ -23,7 +23,9 @@ discard block |
||
| 23 | 23 | function __construct($auto_connect = TRUE) |
| 24 | 24 | { |
| 25 | 25 | $this->_setDBInfo(); |
| 26 | - if($auto_connect) $this->_connect(); |
|
| 26 | + if($auto_connect) { |
|
| 27 | + $this->_connect(); |
|
| 28 | + } |
|
| 27 | 29 | } |
| 28 | 30 | |
| 29 | 31 | /** |
@@ -58,8 +60,7 @@ discard block |
||
| 58 | 60 | if(!$transactionLevel) |
| 59 | 61 | { |
| 60 | 62 | $this->_query("START TRANSACTION", $connection); |
| 61 | - } |
|
| 62 | - else |
|
| 63 | + } else |
|
| 63 | 64 | { |
| 64 | 65 | $this->_query("SAVEPOINT SP" . $transactionLevel, $connection); |
| 65 | 66 | } |
@@ -80,8 +81,7 @@ discard block |
||
| 80 | 81 | if($point) |
| 81 | 82 | { |
| 82 | 83 | $this->_query("ROLLBACK TO SP" . $point, $connection); |
| 83 | - } |
|
| 84 | - else |
|
| 84 | + } else |
|
| 85 | 85 | { |
| 86 | 86 | $this->_query("ROLLBACK", $connection); |
| 87 | 87 | } |
@@ -149,8 +149,7 @@ discard block |
||
| 149 | 149 | if(!is_array($xml_obj->table->column)) |
| 150 | 150 | { |
| 151 | 151 | $columns[] = $xml_obj->table->column; |
| 152 | - } |
|
| 153 | - else |
|
| 152 | + } else |
|
| 154 | 153 | { |
| 155 | 154 | $columns = $xml_obj->table->column; |
| 156 | 155 | } |
@@ -172,12 +171,10 @@ discard block |
||
| 172 | 171 | if($primary_key) |
| 173 | 172 | { |
| 174 | 173 | $primary_list[] = $name; |
| 175 | - } |
|
| 176 | - else if($unique) |
|
| 174 | + } else if($unique) |
|
| 177 | 175 | { |
| 178 | 176 | $unique_list[$unique][] = $name; |
| 179 | - } |
|
| 180 | - else if($index) |
|
| 177 | + } else if($index) |
|
| 181 | 178 | { |
| 182 | 179 | $index_list[$index][] = $name; |
| 183 | 180 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | function __construct($auto_connect = TRUE) |
| 24 | 24 | { |
| 25 | 25 | $this->_setDBInfo(); |
| 26 | - if($auto_connect) $this->_connect(); |
|
| 26 | + if ($auto_connect) $this->_connect(); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -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,18 +132,18 @@ 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 | - $this->setError(-1, "Invalid arguments: $query" . mysqli_error($connection)); |
|
| 137 | + $this->setError(-1, "Invalid arguments: $query".mysqli_error($connection)); |
|
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | // 3. Execute query |
| 142 | 142 | $status = mysqli_stmt_execute($stmt); |
| 143 | 143 | |
| 144 | - if(!$status) |
|
| 144 | + if (!$status) |
|
| 145 | 145 | { |
| 146 | - $this->setError(-1, "Prepared statement failed: $query" . mysqli_error($connection)); |
|
| 146 | + $this->setError(-1, "Prepared statement failed: $query".mysqli_error($connection)); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | // Return stmt for other processing - like retrieving resultset (_fetch) |
@@ -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,25 +247,25 @@ 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 | - $field->name = 'repeat_' . $field->name; |
|
| 254 | + $field->name = 'repeat_'.$field->name; |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | // Array passed needs to contain references, not values |
| 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 | } |
@@ -23,7 +23,9 @@ discard block |
||
| 23 | 23 | function __construct($auto_connect = TRUE) |
| 24 | 24 | { |
| 25 | 25 | $this->_setDBInfo(); |
| 26 | - if($auto_connect) $this->_connect(); |
|
| 26 | + if($auto_connect) { |
|
| 27 | + $this->_connect(); |
|
| 28 | + } |
|
| 27 | 29 | } |
| 28 | 30 | |
| 29 | 31 | /** |
@@ -51,8 +53,7 @@ discard block |
||
| 51 | 53 | , $connection["db_password"] |
| 52 | 54 | , $connection["db_database"] |
| 53 | 55 | , $connection["db_port"]); |
| 54 | - } |
|
| 55 | - else |
|
| 56 | + } else |
|
| 56 | 57 | { |
| 57 | 58 | $result = @mysqli_connect($connection["db_hostname"] |
| 58 | 59 | , $connection["db_userid"] |
@@ -209,8 +210,7 @@ discard block |
||
| 209 | 210 | $params[] = $v; |
| 210 | 211 | $types .= $type; |
| 211 | 212 | } |
| 212 | - } |
|
| 213 | - else |
|
| 213 | + } else |
|
| 214 | 214 | { |
| 215 | 215 | $params[] = $value; |
| 216 | 216 | $types .= $type; |
@@ -249,10 +249,12 @@ discard block |
||
| 249 | 249 | $longtext_exists = false; |
| 250 | 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])) { |
|
| 253 | + // When joined tables are used and the same column name appears twice, we should add it separately, otherwise bind_result fails |
|
| 253 | 254 | { |
| 254 | 255 | $field->name = 'repeat_' . $field->name; |
| 255 | 256 | } |
| 257 | + } |
|
| 256 | 258 | |
| 257 | 259 | // Array passed needs to contain references, not values |
| 258 | 260 | $row[$field->name] = ""; |
@@ -301,8 +303,7 @@ discard block |
||
| 301 | 303 | { |
| 302 | 304 | $output[$arrayIndexEndValue--] = $row; |
| 303 | 305 | } |
| 304 | - } |
|
| 305 | - else |
|
| 306 | + } else |
|
| 306 | 307 | { |
| 307 | 308 | $output = $rows; |
| 308 | 309 | } |
@@ -312,8 +313,7 @@ discard block |
||
| 312 | 313 | if(isset($arrayIndexEndValue)) |
| 313 | 314 | { |
| 314 | 315 | return $output; |
| 315 | - } |
|
| 316 | - else |
|
| 316 | + } else |
|
| 317 | 317 | { |
| 318 | 318 | return $output[0]; |
| 319 | 319 | } |