@@ -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 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | function __construct($auto_connect = TRUE) |
| 53 | 53 | { |
| 54 | 54 | $this->_setDBInfo(); |
| 55 | - if($auto_connect) $this->_connect(); |
|
| 55 | + if ($auto_connect) $this->_connect(); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -76,21 +76,21 @@ discard block |
||
| 76 | 76 | $result = @cubrid_connect($connection["db_hostname"], $connection["db_port"], $connection["db_database"], $connection["db_userid"], $connection["db_password"]); |
| 77 | 77 | |
| 78 | 78 | // check connections |
| 79 | - if(!$result) |
|
| 79 | + if (!$result) |
|
| 80 | 80 | { |
| 81 | 81 | $this->setError(-1, 'database connect fail'); |
| 82 | 82 | return; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - if(!defined('__CUBRID_VERSION__')) |
|
| 85 | + if (!defined('__CUBRID_VERSION__')) |
|
| 86 | 86 | { |
| 87 | 87 | $cubrid_version = cubrid_get_server_info($result); |
| 88 | 88 | $cubrid_version_elem = explode('.', $cubrid_version); |
| 89 | - $cubrid_version = $cubrid_version_elem[0] . '.' . $cubrid_version_elem[1] . '.' . $cubrid_version_elem[2]; |
|
| 89 | + $cubrid_version = $cubrid_version_elem[0].'.'.$cubrid_version_elem[1].'.'.$cubrid_version_elem[2]; |
|
| 90 | 90 | define('__CUBRID_VERSION__', $cubrid_version); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - if(__CUBRID_VERSION__ >= '8.4.0') |
|
| 93 | + if (__CUBRID_VERSION__ >= '8.4.0') |
|
| 94 | 94 | cubrid_set_autocommit($result, CUBRID_AUTOCOMMIT_TRUE); |
| 95 | 95 | |
| 96 | 96 | return $result; |
@@ -116,13 +116,13 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | function addQuotes($string) |
| 118 | 118 | { |
| 119 | - if(version_compare(PHP_VERSION, "5.4.0", "<") && |
|
| 119 | + if (version_compare(PHP_VERSION, "5.4.0", "<") && |
|
| 120 | 120 | get_magic_quotes_gpc()) |
| 121 | 121 | { |
| 122 | 122 | $string = stripslashes(str_replace("\\", "\\\\", $string)); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - if(!is_numeric($string)) |
|
| 125 | + if (!is_numeric($string)) |
|
| 126 | 126 | { |
| 127 | 127 | /* |
| 128 | 128 | if ($this->isConnected()) { |
@@ -146,17 +146,17 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | function _begin($transactionLevel = 0) |
| 148 | 148 | { |
| 149 | - if(__CUBRID_VERSION__ >= '8.4.0') |
|
| 149 | + if (__CUBRID_VERSION__ >= '8.4.0') |
|
| 150 | 150 | { |
| 151 | 151 | $connection = $this->_getConnection('master'); |
| 152 | 152 | |
| 153 | - if(!$transactionLevel) |
|
| 153 | + if (!$transactionLevel) |
|
| 154 | 154 | { |
| 155 | 155 | cubrid_set_autocommit($connection, CUBRID_AUTOCOMMIT_FALSE); |
| 156 | 156 | } |
| 157 | 157 | else |
| 158 | 158 | { |
| 159 | - $this->_query("SAVEPOINT SP" . $transactionLevel, $connection); |
|
| 159 | + $this->_query("SAVEPOINT SP".$transactionLevel, $connection); |
|
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | return TRUE; |
@@ -173,9 +173,9 @@ discard block |
||
| 173 | 173 | |
| 174 | 174 | $point = $transactionLevel - 1; |
| 175 | 175 | |
| 176 | - if($point) |
|
| 176 | + if ($point) |
|
| 177 | 177 | { |
| 178 | - $this->_query("ROLLBACK TO SP" . $point, $connection); |
|
| 178 | + $this->_query("ROLLBACK TO SP".$point, $connection); |
|
| 179 | 179 | } |
| 180 | 180 | else |
| 181 | 181 | { |
@@ -206,29 +206,29 @@ discard block |
||
| 206 | 206 | */ |
| 207 | 207 | function __query($query, $connection) |
| 208 | 208 | { |
| 209 | - if($this->use_prepared_statements == 'Y') |
|
| 209 | + if ($this->use_prepared_statements == 'Y') |
|
| 210 | 210 | { |
| 211 | 211 | $req = @cubrid_prepare($connection, $query); |
| 212 | - if(!$req) |
|
| 212 | + if (!$req) |
|
| 213 | 213 | { |
| 214 | 214 | $this->_setError(); |
| 215 | 215 | return false; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | $position = 0; |
| 219 | - if($this->param) |
|
| 219 | + if ($this->param) |
|
| 220 | 220 | { |
| 221 | - foreach($this->param as $param) |
|
| 221 | + foreach ($this->param as $param) |
|
| 222 | 222 | { |
| 223 | 223 | $value = $param->getUnescapedValue(); |
| 224 | 224 | $type = $param->getType(); |
| 225 | 225 | |
| 226 | - if($param->isColumnName()) |
|
| 226 | + if ($param->isColumnName()) |
|
| 227 | 227 | { |
| 228 | 228 | continue; |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - switch($type) |
|
| 231 | + switch ($type) |
|
| 232 | 232 | { |
| 233 | 233 | case 'number' : |
| 234 | 234 | $bind_type = 'numeric'; |
@@ -240,12 +240,12 @@ discard block |
||
| 240 | 240 | $bind_type = 'string'; |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | - if(is_array($value)) |
|
| 243 | + if (is_array($value)) |
|
| 244 | 244 | { |
| 245 | - foreach($value as $v) |
|
| 245 | + foreach ($value as $v) |
|
| 246 | 246 | { |
| 247 | 247 | $bound = @cubrid_bind($req, ++$position, $v, $bind_type); |
| 248 | - if(!$bound) |
|
| 248 | + if (!$bound) |
|
| 249 | 249 | { |
| 250 | 250 | $this->_setError(); |
| 251 | 251 | return false; |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | else |
| 256 | 256 | { |
| 257 | 257 | $bound = @cubrid_bind($req, ++$position, $value, $bind_type); |
| 258 | - if(!$bound) |
|
| 258 | + if (!$bound) |
|
| 259 | 259 | { |
| 260 | 260 | $this->_setError(); |
| 261 | 261 | return false; |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | $result = @cubrid_execute($req); |
| 268 | - if(!$result) |
|
| 268 | + if (!$result) |
|
| 269 | 269 | { |
| 270 | 270 | $this->_setError(); |
| 271 | 271 | return false; |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | // Execute the query |
| 276 | 276 | $result = @cubrid_execute($connection, $query); |
| 277 | 277 | // error check |
| 278 | - if(!$result) |
|
| 278 | + if (!$result) |
|
| 279 | 279 | { |
| 280 | 280 | $this->_setError(); |
| 281 | 281 | return false; |
@@ -306,12 +306,12 @@ discard block |
||
| 306 | 306 | function _fetch($result, $arrayIndexEndValue = NULL) |
| 307 | 307 | { |
| 308 | 308 | $output = array(); |
| 309 | - if(!$this->isConnected() || $this->isError() || !$result) |
|
| 309 | + if (!$this->isConnected() || $this->isError() || !$result) |
|
| 310 | 310 | { |
| 311 | 311 | return array(); |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - if($this->use_prepared_statements == 'Y') |
|
| 314 | + if ($this->use_prepared_statements == 'Y') |
|
| 315 | 315 | { |
| 316 | 316 | |
| 317 | 317 | } |
@@ -322,25 +322,25 @@ discard block |
||
| 322 | 322 | $col_names = cubrid_column_names($result); |
| 323 | 323 | $max = count($col_types); |
| 324 | 324 | |
| 325 | - for($count = 0; $count < $max; $count++) |
|
| 325 | + for ($count = 0; $count < $max; $count++) |
|
| 326 | 326 | { |
| 327 | - if(preg_match("/^char/", $col_types[$count]) > 0) |
|
| 327 | + if (preg_match("/^char/", $col_types[$count]) > 0) |
|
| 328 | 328 | { |
| 329 | 329 | $char_type_fields[] = $col_names[$count]; |
| 330 | 330 | } |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - while($tmp = cubrid_fetch($result, CUBRID_OBJECT)) |
|
| 333 | + while ($tmp = cubrid_fetch($result, CUBRID_OBJECT)) |
|
| 334 | 334 | { |
| 335 | - if(is_array($char_type_fields)) |
|
| 335 | + if (is_array($char_type_fields)) |
|
| 336 | 336 | { |
| 337 | - foreach($char_type_fields as $val) |
|
| 337 | + foreach ($char_type_fields as $val) |
|
| 338 | 338 | { |
| 339 | 339 | $tmp->{$val} = rtrim($tmp->{$val}); |
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - if($arrayIndexEndValue) |
|
| 343 | + if ($arrayIndexEndValue) |
|
| 344 | 344 | { |
| 345 | 345 | $output[$arrayIndexEndValue--] = $tmp; |
| 346 | 346 | } |
@@ -352,15 +352,15 @@ discard block |
||
| 352 | 352 | |
| 353 | 353 | unset($char_type_fields); |
| 354 | 354 | |
| 355 | - if($result) |
|
| 355 | + if ($result) |
|
| 356 | 356 | { |
| 357 | 357 | cubrid_close_request($result); |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - if(count($output) == 1) |
|
| 360 | + if (count($output) == 1) |
|
| 361 | 361 | { |
| 362 | 362 | // If call is made for pagination, always return array |
| 363 | - if(isset($arrayIndexEndValue)) |
|
| 363 | + if (isset($arrayIndexEndValue)) |
|
| 364 | 364 | { |
| 365 | 365 | return $output; |
| 366 | 366 | } |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | */ |
| 396 | 396 | function _makeSequence() |
| 397 | 397 | { |
| 398 | - if($_GLOBALS['XE_EXISTS_SEQUENCE']) |
|
| 398 | + if ($_GLOBALS['XE_EXISTS_SEQUENCE']) |
|
| 399 | 399 | return; |
| 400 | 400 | |
| 401 | 401 | // check cubrid serial |
@@ -404,21 +404,21 @@ discard block |
||
| 404 | 404 | $output = $this->_fetch($result); |
| 405 | 405 | |
| 406 | 406 | // if do not create serial |
| 407 | - if($output->count == 0) |
|
| 408 | - { |
|
| 409 | - $query = sprintf('select max("a"."srl") as "srl" from ' . |
|
| 410 | - '( select max("document_srl") as "srl" from ' . |
|
| 411 | - '"%sdocuments" UNION ' . |
|
| 412 | - 'select max("comment_srl") as "srl" from ' . |
|
| 413 | - '"%scomments" UNION ' . |
|
| 414 | - 'select max("member_srl") as "srl" from ' . |
|
| 415 | - '"%smember"' . |
|
| 407 | + if ($output->count == 0) |
|
| 408 | + { |
|
| 409 | + $query = sprintf('select max("a"."srl") as "srl" from '. |
|
| 410 | + '( select max("document_srl") as "srl" from '. |
|
| 411 | + '"%sdocuments" UNION '. |
|
| 412 | + 'select max("comment_srl") as "srl" from '. |
|
| 413 | + '"%scomments" UNION '. |
|
| 414 | + 'select max("member_srl") as "srl" from '. |
|
| 415 | + '"%smember"'. |
|
| 416 | 416 | ') as "a"', $this->prefix, $this->prefix, $this->prefix); |
| 417 | 417 | |
| 418 | 418 | $result = $this->_query($query); |
| 419 | 419 | $output = $this->_fetch($result); |
| 420 | 420 | $srl = $output->srl; |
| 421 | - if($srl < 1) |
|
| 421 | + if ($srl < 1) |
|
| 422 | 422 | { |
| 423 | 423 | $start = 1; |
| 424 | 424 | } |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | */ |
| 443 | 443 | function isTableExists($target_name) |
| 444 | 444 | { |
| 445 | - if($target_name == 'sequence') |
|
| 445 | + if ($target_name == 'sequence') |
|
| 446 | 446 | { |
| 447 | 447 | $query = sprintf("select \"name\" from \"db_serial\" where \"name\" = '%s%s'", $this->prefix, $target_name); |
| 448 | 448 | } |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | $result = $this->_query($query); |
| 455 | - if(cubrid_num_rows($result) > 0) |
|
| 455 | + if (cubrid_num_rows($result) > 0) |
|
| 456 | 456 | { |
| 457 | 457 | $output = TRUE; |
| 458 | 458 | } |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | $output = FALSE; |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | - if($result) |
|
| 464 | + if ($result) |
|
| 465 | 465 | { |
| 466 | 466 | cubrid_close_request($result); |
| 467 | 467 | } |
@@ -482,22 +482,22 @@ discard block |
||
| 482 | 482 | function addColumn($table_name, $column_name, $type = 'number', $size = '', $default = null, $notnull = FALSE) |
| 483 | 483 | { |
| 484 | 484 | $type = strtoupper($this->column_type[$type]); |
| 485 | - if($type == 'INTEGER') |
|
| 485 | + if ($type == 'INTEGER') |
|
| 486 | 486 | { |
| 487 | 487 | $size = ''; |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | $query = sprintf("alter class \"%s%s\" add \"%s\" ", $this->prefix, $table_name, $column_name); |
| 491 | 491 | |
| 492 | - if($type == 'char' || $type == 'varchar') |
|
| 492 | + if ($type == 'char' || $type == 'varchar') |
|
| 493 | 493 | { |
| 494 | - if($size) |
|
| 494 | + if ($size) |
|
| 495 | 495 | { |
| 496 | 496 | $size = $size * 3; |
| 497 | 497 | } |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | - if($size) |
|
| 500 | + if ($size) |
|
| 501 | 501 | { |
| 502 | 502 | $query .= sprintf("%s(%s) ", $type, $size); |
| 503 | 503 | } |
@@ -506,9 +506,9 @@ discard block |
||
| 506 | 506 | $query .= sprintf("%s ", $type); |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | - if(isset($default)) |
|
| 509 | + if (isset($default)) |
|
| 510 | 510 | { |
| 511 | - if($type == 'INTEGER' || $type == 'BIGINT' || $type == 'INT') |
|
| 511 | + if ($type == 'INTEGER' || $type == 'BIGINT' || $type == 'INT') |
|
| 512 | 512 | { |
| 513 | 513 | $query .= sprintf("default %d ", $default); |
| 514 | 514 | } |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | } |
| 519 | 519 | } |
| 520 | 520 | |
| 521 | - if($notnull) |
|
| 521 | + if ($notnull) |
|
| 522 | 522 | { |
| 523 | 523 | $query .= "not null "; |
| 524 | 524 | } |
@@ -547,10 +547,10 @@ discard block |
||
| 547 | 547 | */ |
| 548 | 548 | function isColumnExists($table_name, $column_name) |
| 549 | 549 | { |
| 550 | - $query = sprintf("select \"attr_name\" from \"db_attribute\" where " . "\"attr_name\" ='%s' and \"class_name\" = '%s%s'", $column_name, $this->prefix, $table_name); |
|
| 550 | + $query = sprintf("select \"attr_name\" from \"db_attribute\" where "."\"attr_name\" ='%s' and \"class_name\" = '%s%s'", $column_name, $this->prefix, $table_name); |
|
| 551 | 551 | $result = $this->_query($query); |
| 552 | 552 | |
| 553 | - if(cubrid_num_rows($result) > 0) |
|
| 553 | + if (cubrid_num_rows($result) > 0) |
|
| 554 | 554 | { |
| 555 | 555 | $output = TRUE; |
| 556 | 556 | } |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | $output = FALSE; |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | - if($result) |
|
| 562 | + if ($result) |
|
| 563 | 563 | { |
| 564 | 564 | cubrid_close_request($result); |
| 565 | 565 | } |
@@ -579,12 +579,12 @@ discard block |
||
| 579 | 579 | */ |
| 580 | 580 | function addIndex($table_name, $index_name, $target_columns, $is_unique = FALSE) |
| 581 | 581 | { |
| 582 | - if(!is_array($target_columns)) |
|
| 582 | + if (!is_array($target_columns)) |
|
| 583 | 583 | { |
| 584 | 584 | $target_columns = array($target_columns); |
| 585 | 585 | } |
| 586 | 586 | |
| 587 | - $query = sprintf("create %s index \"%s\" on \"%s%s\" (%s);", $is_unique ? 'unique' : '', $index_name, $this->prefix, $table_name, '"' . implode('","', $target_columns) . '"'); |
|
| 587 | + $query = sprintf("create %s index \"%s\" on \"%s%s\" (%s);", $is_unique ? 'unique' : '', $index_name, $this->prefix, $table_name, '"'.implode('","', $target_columns).'"'); |
|
| 588 | 588 | |
| 589 | 589 | $this->_query($query); |
| 590 | 590 | } |
@@ -611,17 +611,17 @@ discard block |
||
| 611 | 611 | */ |
| 612 | 612 | function isIndexExists($table_name, $index_name) |
| 613 | 613 | { |
| 614 | - $query = sprintf("select \"index_name\" from \"db_index\" where " . "\"class_name\" = '%s%s' and (\"index_name\" = '%s' or \"index_name\" = '%s') ", $this->prefix, $table_name, $this->prefix . $index_name, $index_name); |
|
| 614 | + $query = sprintf("select \"index_name\" from \"db_index\" where "."\"class_name\" = '%s%s' and (\"index_name\" = '%s' or \"index_name\" = '%s') ", $this->prefix, $table_name, $this->prefix.$index_name, $index_name); |
|
| 615 | 615 | $result = $this->_query($query); |
| 616 | 616 | |
| 617 | - if($this->isError()) |
|
| 617 | + if ($this->isError()) |
|
| 618 | 618 | { |
| 619 | 619 | return FALSE; |
| 620 | 620 | } |
| 621 | 621 | |
| 622 | 622 | $output = $this->_fetch($result); |
| 623 | 623 | |
| 624 | - if(!$output) |
|
| 624 | + if (!$output) |
|
| 625 | 625 | { |
| 626 | 626 | return FALSE; |
| 627 | 627 | } |
@@ -653,25 +653,25 @@ discard block |
||
| 653 | 653 | ", strlen($this->prefix) |
| 654 | 654 | , $this->prefix |
| 655 | 655 | , strlen($this->prefix) + 1 |
| 656 | - , "'" . $this->prefix . '%' . "'" |
|
| 656 | + , "'".$this->prefix.'%'."'" |
|
| 657 | 657 | , strlen($this->prefix) |
| 658 | 658 | , $this->prefix |
| 659 | 659 | , strlen($this->prefix) + 1 |
| 660 | 660 | ); |
| 661 | 661 | $result = $this->_query($query); |
| 662 | 662 | |
| 663 | - if($this->isError()) |
|
| 663 | + if ($this->isError()) |
|
| 664 | 664 | { |
| 665 | 665 | return FALSE; |
| 666 | 666 | } |
| 667 | 667 | |
| 668 | 668 | $output = $this->_fetch($result); |
| 669 | - if(!$output) |
|
| 669 | + if (!$output) |
|
| 670 | 670 | { |
| 671 | 671 | return FALSE; |
| 672 | 672 | } |
| 673 | 673 | |
| 674 | - if(!is_array($output)) |
|
| 674 | + if (!is_array($output)) |
|
| 675 | 675 | { |
| 676 | 676 | $indexes_to_be_deleted = array($output); |
| 677 | 677 | } |
@@ -680,10 +680,10 @@ discard block |
||
| 680 | 680 | $indexes_to_be_deleted = $output; |
| 681 | 681 | } |
| 682 | 682 | |
| 683 | - foreach($indexes_to_be_deleted as $index) |
|
| 683 | + foreach ($indexes_to_be_deleted as $index) |
|
| 684 | 684 | { |
| 685 | 685 | $this->dropIndex(substr($index->class_name, strlen($this->prefix)) |
| 686 | - , $this->prefix . $index->unprefixed_index_name |
|
| 686 | + , $this->prefix.$index->unprefixed_index_name |
|
| 687 | 687 | , $index->is_unique == 'YES' ? TRUE : FALSE); |
| 688 | 688 | } |
| 689 | 689 | |
@@ -707,7 +707,7 @@ discard block |
||
| 707 | 707 | */ |
| 708 | 708 | function createTableByXmlFile($file_name) |
| 709 | 709 | { |
| 710 | - if(!file_exists($file_name)) |
|
| 710 | + if (!file_exists($file_name)) |
|
| 711 | 711 | { |
| 712 | 712 | return; |
| 713 | 713 | } |
@@ -734,28 +734,28 @@ discard block |
||
| 734 | 734 | $table_name = $xml_obj->table->attrs->name; |
| 735 | 735 | |
| 736 | 736 | // if the table already exists exit function |
| 737 | - if($this->isTableExists($table_name)) |
|
| 737 | + if ($this->isTableExists($table_name)) |
|
| 738 | 738 | { |
| 739 | 739 | return; |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | 742 | // If the table name is sequence, it creates a serial |
| 743 | - if($table_name == 'sequence') |
|
| 743 | + if ($table_name == 'sequence') |
|
| 744 | 744 | { |
| 745 | - $query = sprintf('create serial "%s" start with 1 increment by 1' . |
|
| 746 | - ' minvalue 1 ' . |
|
| 747 | - 'maxvalue 10000000000000000000000000000000000000' . ' nocycle;', $this->prefix . $table_name); |
|
| 745 | + $query = sprintf('create serial "%s" start with 1 increment by 1'. |
|
| 746 | + ' minvalue 1 '. |
|
| 747 | + 'maxvalue 10000000000000000000000000000000000000'.' nocycle;', $this->prefix.$table_name); |
|
| 748 | 748 | |
| 749 | 749 | return $this->_query($query); |
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | |
| 753 | - $table_name = $this->prefix . $table_name; |
|
| 753 | + $table_name = $this->prefix.$table_name; |
|
| 754 | 754 | |
| 755 | 755 | $query = sprintf('create class "%s";', $table_name); |
| 756 | 756 | $this->_query($query); |
| 757 | 757 | |
| 758 | - if(!is_array($xml_obj->table->column)) |
|
| 758 | + if (!is_array($xml_obj->table->column)) |
|
| 759 | 759 | { |
| 760 | 760 | $columns[] = $xml_obj->table->column; |
| 761 | 761 | } |
@@ -770,7 +770,7 @@ discard block |
||
| 770 | 770 | $unique_list = array(); |
| 771 | 771 | $index_list = array(); |
| 772 | 772 | |
| 773 | - foreach($columns as $column) |
|
| 773 | + foreach ($columns as $column) |
|
| 774 | 774 | { |
| 775 | 775 | $name = $column->attrs->name; |
| 776 | 776 | $type = $column->attrs->type; |
@@ -781,7 +781,7 @@ discard block |
||
| 781 | 781 | $unique = $column->attrs->unique; |
| 782 | 782 | $default = $column->attrs->default; |
| 783 | 783 | |
| 784 | - switch($this->column_type[$type]) |
|
| 784 | + switch ($this->column_type[$type]) |
|
| 785 | 785 | { |
| 786 | 786 | case 'integer' : |
| 787 | 787 | $size = NULL; |
@@ -791,58 +791,58 @@ discard block |
||
| 791 | 791 | break; |
| 792 | 792 | } |
| 793 | 793 | |
| 794 | - if(isset($default) && ($type == 'varchar' || $type == 'char' || |
|
| 794 | + if (isset($default) && ($type == 'varchar' || $type == 'char' || |
|
| 795 | 795 | $type == 'text' || $type == 'tinytext' || $type == 'bigtext')) |
| 796 | 796 | { |
| 797 | 797 | $default = sprintf("'%s'", $default); |
| 798 | 798 | } |
| 799 | 799 | |
| 800 | - if($type == 'varchar' || $type == 'char') |
|
| 800 | + if ($type == 'varchar' || $type == 'char') |
|
| 801 | 801 | { |
| 802 | - if($size) |
|
| 802 | + if ($size) |
|
| 803 | 803 | $size = $size * 3; |
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 | |
| 807 | - $column_schema[] = sprintf('"%s" %s%s %s %s', $name, $this->column_type[$type], $size ? '(' . $size . ')' : '', isset($default) ? "default " . $default : '', $notnull ? 'not null' : ''); |
|
| 807 | + $column_schema[] = sprintf('"%s" %s%s %s %s', $name, $this->column_type[$type], $size ? '('.$size.')' : '', isset($default) ? "default ".$default : '', $notnull ? 'not null' : ''); |
|
| 808 | 808 | |
| 809 | - if($primary_key) |
|
| 809 | + if ($primary_key) |
|
| 810 | 810 | { |
| 811 | 811 | $primary_list[] = $name; |
| 812 | 812 | } |
| 813 | - else if($unique) |
|
| 813 | + else if ($unique) |
|
| 814 | 814 | { |
| 815 | 815 | $unique_list[$unique][] = $name; |
| 816 | 816 | } |
| 817 | - else if($index) |
|
| 817 | + else if ($index) |
|
| 818 | 818 | { |
| 819 | 819 | $index_list[$index][] = $name; |
| 820 | 820 | } |
| 821 | 821 | } |
| 822 | 822 | |
| 823 | - $query .= implode(',', $column_schema) . ';'; |
|
| 823 | + $query .= implode(',', $column_schema).';'; |
|
| 824 | 824 | $this->_query($query); |
| 825 | 825 | |
| 826 | - if(count($primary_list)) |
|
| 826 | + if (count($primary_list)) |
|
| 827 | 827 | { |
| 828 | - $query = sprintf("alter class \"%s\" add attribute constraint " . "\"pkey_%s\" PRIMARY KEY(%s);", $table_name, $table_name, '"' . implode('","', $primary_list) . '"'); |
|
| 828 | + $query = sprintf("alter class \"%s\" add attribute constraint "."\"pkey_%s\" PRIMARY KEY(%s);", $table_name, $table_name, '"'.implode('","', $primary_list).'"'); |
|
| 829 | 829 | $this->_query($query); |
| 830 | 830 | } |
| 831 | 831 | |
| 832 | - if(count($unique_list)) |
|
| 832 | + if (count($unique_list)) |
|
| 833 | 833 | { |
| 834 | - foreach($unique_list as $key => $val) |
|
| 834 | + foreach ($unique_list as $key => $val) |
|
| 835 | 835 | { |
| 836 | - $query = sprintf("create unique index \"%s\" on \"%s\" " . "(%s);", $key, $table_name, '"' . implode('","', $val) . '"'); |
|
| 836 | + $query = sprintf("create unique index \"%s\" on \"%s\" "."(%s);", $key, $table_name, '"'.implode('","', $val).'"'); |
|
| 837 | 837 | $this->_query($query); |
| 838 | 838 | } |
| 839 | 839 | } |
| 840 | 840 | |
| 841 | - if(count($index_list)) |
|
| 841 | + if (count($index_list)) |
|
| 842 | 842 | { |
| 843 | - foreach($index_list as $key => $val) |
|
| 843 | + foreach ($index_list as $key => $val) |
|
| 844 | 844 | { |
| 845 | - $query = sprintf("create index \"%s\" on \"%s\" (%s);", $key, $table_name, '"' . implode('","', $val) . '"'); |
|
| 845 | + $query = sprintf("create index \"%s\" on \"%s\" (%s);", $key, $table_name, '"'.implode('","', $val).'"'); |
|
| 846 | 846 | $this->_query($query); |
| 847 | 847 | } |
| 848 | 848 | } |
@@ -856,22 +856,22 @@ discard block |
||
| 856 | 856 | */ |
| 857 | 857 | function _executeInsertAct($queryObject, $with_values = TRUE) |
| 858 | 858 | { |
| 859 | - if($this->use_prepared_statements == 'Y') |
|
| 859 | + if ($this->use_prepared_statements == 'Y') |
|
| 860 | 860 | { |
| 861 | 861 | $this->param = $queryObject->getArguments(); |
| 862 | 862 | $with_values = FALSE; |
| 863 | 863 | } |
| 864 | 864 | $query = $this->getInsertSql($queryObject, $with_values); |
| 865 | - if(is_a($query, 'BaseObject')) |
|
| 865 | + if (is_a($query, 'BaseObject')) |
|
| 866 | 866 | { |
| 867 | 867 | unset($this->param); |
| 868 | 868 | return; |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | - $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
| 871 | + $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
| 872 | 872 | |
| 873 | 873 | $result = $this->_query($query); |
| 874 | - if($result && !$this->transaction_started) |
|
| 874 | + if ($result && !$this->transaction_started) |
|
| 875 | 875 | { |
| 876 | 876 | $this->_commit(); |
| 877 | 877 | } |
@@ -887,23 +887,23 @@ discard block |
||
| 887 | 887 | */ |
| 888 | 888 | function _executeUpdateAct($queryObject, $with_values = TRUE) |
| 889 | 889 | { |
| 890 | - if($this->use_prepared_statements == 'Y') |
|
| 890 | + if ($this->use_prepared_statements == 'Y') |
|
| 891 | 891 | { |
| 892 | 892 | $this->param = $queryObject->getArguments(); |
| 893 | 893 | $with_values = FALSE; |
| 894 | 894 | } |
| 895 | 895 | $query = $this->getUpdateSql($queryObject, $with_values); |
| 896 | - if(is_a($query, 'BaseObject')) |
|
| 896 | + if (is_a($query, 'BaseObject')) |
|
| 897 | 897 | { |
| 898 | 898 | unset($this->param); |
| 899 | 899 | return; |
| 900 | 900 | } |
| 901 | 901 | |
| 902 | - $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
| 902 | + $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
| 903 | 903 | |
| 904 | 904 | $result = $this->_query($query); |
| 905 | 905 | |
| 906 | - if($result && !$this->transaction_started) |
|
| 906 | + if ($result && !$this->transaction_started) |
|
| 907 | 907 | { |
| 908 | 908 | $this->_commit(); |
| 909 | 909 | } |
@@ -919,23 +919,23 @@ discard block |
||
| 919 | 919 | */ |
| 920 | 920 | function _executeDeleteAct($queryObject, $with_values = TRUE) |
| 921 | 921 | { |
| 922 | - if($this->use_prepared_statements == 'Y') |
|
| 922 | + if ($this->use_prepared_statements == 'Y') |
|
| 923 | 923 | { |
| 924 | 924 | $this->param = $queryObject->getArguments(); |
| 925 | 925 | $with_values = FALSE; |
| 926 | 926 | } |
| 927 | 927 | $query = $this->getDeleteSql($queryObject, $with_values); |
| 928 | - if(is_a($query, 'BaseObject')) |
|
| 928 | + if (is_a($query, 'BaseObject')) |
|
| 929 | 929 | { |
| 930 | 930 | unset($this->param); |
| 931 | 931 | return; |
| 932 | 932 | } |
| 933 | 933 | |
| 934 | - $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
| 934 | + $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
| 935 | 935 | |
| 936 | 936 | $result = $this->_query($query); |
| 937 | 937 | |
| 938 | - if($result && !$this->transaction_started) |
|
| 938 | + if ($result && !$this->transaction_started) |
|
| 939 | 939 | { |
| 940 | 940 | $this->_commit(); |
| 941 | 941 | } |
@@ -955,29 +955,29 @@ discard block |
||
| 955 | 955 | */ |
| 956 | 956 | function _executeSelectAct($queryObject, $connection = NULL, $with_values = TRUE) |
| 957 | 957 | { |
| 958 | - if($this->use_prepared_statements == 'Y') |
|
| 958 | + if ($this->use_prepared_statements == 'Y') |
|
| 959 | 959 | { |
| 960 | 960 | $this->param = $queryObject->getArguments(); |
| 961 | 961 | $with_values = FALSE; |
| 962 | 962 | } |
| 963 | 963 | $limit = $queryObject->getLimit(); |
| 964 | - if($limit && $limit->isPageHandler()) |
|
| 964 | + if ($limit && $limit->isPageHandler()) |
|
| 965 | 965 | { |
| 966 | 966 | return $this->queryPageLimit($queryObject, $connection, $with_values); |
| 967 | 967 | } |
| 968 | 968 | else |
| 969 | 969 | { |
| 970 | 970 | $query = $this->getSelectSql($queryObject, $with_values); |
| 971 | - if(is_a($query, 'BaseObject')) |
|
| 971 | + if (is_a($query, 'BaseObject')) |
|
| 972 | 972 | { |
| 973 | 973 | unset($this->param); |
| 974 | 974 | return; |
| 975 | 975 | } |
| 976 | 976 | |
| 977 | - $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
| 977 | + $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
| 978 | 978 | $result = $this->_query($query, $connection); |
| 979 | 979 | |
| 980 | - if($this->isError()) |
|
| 980 | + if ($this->isError()) |
|
| 981 | 981 | { |
| 982 | 982 | unset($this->param); |
| 983 | 983 | return $this->queryError($queryObject); |
@@ -1000,16 +1000,16 @@ discard block |
||
| 1000 | 1000 | function queryError($queryObject) |
| 1001 | 1001 | { |
| 1002 | 1002 | $limit = $queryObject->getLimit(); |
| 1003 | - if($limit && $limit->isPageHandler()) |
|
| 1003 | + if ($limit && $limit->isPageHandler()) |
|
| 1004 | 1004 | { |
| 1005 | - $buff = new BaseObject (); |
|
| 1005 | + $buff = new BaseObject(); |
|
| 1006 | 1006 | $buff->total_count = 0; |
| 1007 | 1007 | $buff->total_page = 0; |
| 1008 | 1008 | $buff->page = 1; |
| 1009 | 1009 | $buff->data = array(); |
| 1010 | 1010 | $buff->page_navigation = new PageHandler(/* $total_count */0, /* $total_page */1, /* $page */1, /* $page_count */10); //default page handler values |
| 1011 | 1011 | return $buff; |
| 1012 | - }else |
|
| 1012 | + } else |
|
| 1013 | 1013 | return; |
| 1014 | 1014 | } |
| 1015 | 1015 | |
@@ -1025,48 +1025,48 @@ discard block |
||
| 1025 | 1025 | $limit = $queryObject->getLimit(); |
| 1026 | 1026 | // Total count |
| 1027 | 1027 | $temp_where = $queryObject->getWhereString($with_values, FALSE); |
| 1028 | - $count_query = sprintf('select count(*) as "count" %s %s', 'FROM ' . $queryObject->getFromString($with_values), ($temp_where === '' ? '' : ' WHERE ' . $temp_where)); |
|
| 1028 | + $count_query = sprintf('select count(*) as "count" %s %s', 'FROM '.$queryObject->getFromString($with_values), ($temp_where === '' ? '' : ' WHERE '.$temp_where)); |
|
| 1029 | 1029 | |
| 1030 | 1030 | // Check for distinct query and if found update count query structure |
| 1031 | 1031 | $temp_select = $queryObject->getSelectString($with_values); |
| 1032 | 1032 | $uses_distinct = stripos($temp_select, "distinct") !== FALSE; |
| 1033 | 1033 | $uses_groupby = $queryObject->getGroupByString() != ''; |
| 1034 | - if($uses_distinct || $uses_groupby) |
|
| 1034 | + if ($uses_distinct || $uses_groupby) |
|
| 1035 | 1035 | { |
| 1036 | 1036 | $count_query = sprintf('select %s %s %s %s' |
| 1037 | 1037 | , $temp_select |
| 1038 | - , 'FROM ' . $queryObject->getFromString($with_values) |
|
| 1039 | - , ($temp_where === '' ? '' : ' WHERE ' . $temp_where) |
|
| 1040 | - , ($uses_groupby ? ' GROUP BY ' . $queryObject->getGroupByString() : '') |
|
| 1038 | + , 'FROM '.$queryObject->getFromString($with_values) |
|
| 1039 | + , ($temp_where === '' ? '' : ' WHERE '.$temp_where) |
|
| 1040 | + , ($uses_groupby ? ' GROUP BY '.$queryObject->getGroupByString() : '') |
|
| 1041 | 1041 | ); |
| 1042 | 1042 | |
| 1043 | 1043 | // If query uses grouping or distinct, count from original select |
| 1044 | 1044 | $count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query); |
| 1045 | 1045 | } |
| 1046 | 1046 | |
| 1047 | - $count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' ' . $this->comment_syntax, $queryObject->queryID) : ''; |
|
| 1047 | + $count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' '.$this->comment_syntax, $queryObject->queryID) : ''; |
|
| 1048 | 1048 | $result = $this->_query($count_query, $connection); |
| 1049 | 1049 | $count_output = $this->_fetch($result); |
| 1050 | 1050 | $total_count = (int) (isset($count_output->count) ? $count_output->count : NULL); |
| 1051 | 1051 | |
| 1052 | 1052 | $list_count = $limit->list_count->getValue(); |
| 1053 | - if(!$list_count) |
|
| 1053 | + if (!$list_count) |
|
| 1054 | 1054 | { |
| 1055 | 1055 | $list_count = 20; |
| 1056 | 1056 | } |
| 1057 | 1057 | $page_count = $limit->page_count->getValue(); |
| 1058 | - if(!$page_count) |
|
| 1058 | + if (!$page_count) |
|
| 1059 | 1059 | { |
| 1060 | 1060 | $page_count = 10; |
| 1061 | 1061 | } |
| 1062 | 1062 | $page = $limit->page->getValue(); |
| 1063 | - if(!$page || $page < 1) |
|
| 1063 | + if (!$page || $page < 1) |
|
| 1064 | 1064 | { |
| 1065 | 1065 | $page = 1; |
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 1068 | 1068 | // total pages |
| 1069 | - if($total_count) |
|
| 1069 | + if ($total_count) |
|
| 1070 | 1070 | { |
| 1071 | 1071 | $total_page = (int) (($total_count - 1) / $list_count) + 1; |
| 1072 | 1072 | } |
@@ -1076,7 +1076,7 @@ discard block |
||
| 1076 | 1076 | } |
| 1077 | 1077 | |
| 1078 | 1078 | // check the page variables |
| 1079 | - if($page > $total_page) |
|
| 1079 | + if ($page > $total_page) |
|
| 1080 | 1080 | { |
| 1081 | 1081 | // If requested page is bigger than total number of pages, return empty list |
| 1082 | 1082 | |
@@ -1092,9 +1092,9 @@ discard block |
||
| 1092 | 1092 | $start_count = ($page - 1) * $list_count; |
| 1093 | 1093 | |
| 1094 | 1094 | $query = $this->getSelectPageSql($queryObject, $with_values, $start_count, $list_count); |
| 1095 | - $query .= (__DEBUG_QUERY__ & 1 && $queryObject->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
| 1095 | + $query .= (__DEBUG_QUERY__ & 1 && $queryObject->query_id) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
| 1096 | 1096 | $result = $this->_query($query, $connection); |
| 1097 | - if($this->isError()) |
|
| 1097 | + if ($this->isError()) |
|
| 1098 | 1098 | { |
| 1099 | 1099 | unset($this->param); |
| 1100 | 1100 | return $this->queryError($queryObject); |
@@ -1135,44 +1135,44 @@ discard block |
||
| 1135 | 1135 | { |
| 1136 | 1136 | |
| 1137 | 1137 | $select = $query->getSelectString($with_values); |
| 1138 | - if($select == '') |
|
| 1138 | + if ($select == '') |
|
| 1139 | 1139 | { |
| 1140 | 1140 | return new BaseObject(-1, "Invalid query"); |
| 1141 | 1141 | } |
| 1142 | - $select = 'SELECT ' . $select; |
|
| 1142 | + $select = 'SELECT '.$select; |
|
| 1143 | 1143 | |
| 1144 | 1144 | $from = $query->getFromString($with_values); |
| 1145 | - if($from == '') |
|
| 1145 | + if ($from == '') |
|
| 1146 | 1146 | { |
| 1147 | 1147 | return new BaseObject(-1, "Invalid query"); |
| 1148 | 1148 | } |
| 1149 | - $from = ' FROM ' . $from; |
|
| 1149 | + $from = ' FROM '.$from; |
|
| 1150 | 1150 | |
| 1151 | 1151 | $where = $query->getWhereString($with_values); |
| 1152 | - if($where != '') |
|
| 1152 | + if ($where != '') |
|
| 1153 | 1153 | { |
| 1154 | - $where = ' WHERE ' . $where; |
|
| 1154 | + $where = ' WHERE '.$where; |
|
| 1155 | 1155 | } |
| 1156 | 1156 | |
| 1157 | 1157 | $groupBy = $query->getGroupByString(); |
| 1158 | - if($groupBy != '') |
|
| 1158 | + if ($groupBy != '') |
|
| 1159 | 1159 | { |
| 1160 | - $groupBy = ' GROUP BY ' . $groupBy; |
|
| 1160 | + $groupBy = ' GROUP BY '.$groupBy; |
|
| 1161 | 1161 | } |
| 1162 | 1162 | |
| 1163 | 1163 | $orderBy = $query->getOrderByString(); |
| 1164 | - if($orderBy != '') |
|
| 1164 | + if ($orderBy != '') |
|
| 1165 | 1165 | { |
| 1166 | - $orderBy = ' ORDER BY ' . $orderBy; |
|
| 1166 | + $orderBy = ' ORDER BY '.$orderBy; |
|
| 1167 | 1167 | } |
| 1168 | 1168 | |
| 1169 | 1169 | $limit = $query->getLimitString(); |
| 1170 | - if($limit != '') |
|
| 1170 | + if ($limit != '') |
|
| 1171 | 1171 | { |
| 1172 | 1172 | $limit = sprintf(' LIMIT %d, %d', $start_count, $list_count); |
| 1173 | 1173 | } |
| 1174 | 1174 | |
| 1175 | - return $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit; |
|
| 1175 | + return $select.' '.$from.' '.$where.' '.$groupBy.' '.$orderBy.' '.$limit; |
|
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | 1178 | } |
@@ -52,7 +52,9 @@ discard block |
||
| 52 | 52 | function __construct($auto_connect = TRUE) |
| 53 | 53 | { |
| 54 | 54 | $this->_setDBInfo(); |
| 55 | - if($auto_connect) $this->_connect(); |
|
| 55 | + if($auto_connect) { |
|
| 56 | + $this->_connect(); |
|
| 57 | + } |
|
| 56 | 58 | } |
| 57 | 59 | |
| 58 | 60 | /** |
@@ -90,8 +92,9 @@ discard block |
||
| 90 | 92 | define('__CUBRID_VERSION__', $cubrid_version); |
| 91 | 93 | } |
| 92 | 94 | |
| 93 | - if(__CUBRID_VERSION__ >= '8.4.0') |
|
| 94 | - cubrid_set_autocommit($result, CUBRID_AUTOCOMMIT_TRUE); |
|
| 95 | + if(__CUBRID_VERSION__ >= '8.4.0') { |
|
| 96 | + cubrid_set_autocommit($result, CUBRID_AUTOCOMMIT_TRUE); |
|
| 97 | + } |
|
| 95 | 98 | |
| 96 | 99 | return $result; |
| 97 | 100 | } |
@@ -153,8 +156,7 @@ discard block |
||
| 153 | 156 | if(!$transactionLevel) |
| 154 | 157 | { |
| 155 | 158 | cubrid_set_autocommit($connection, CUBRID_AUTOCOMMIT_FALSE); |
| 156 | - } |
|
| 157 | - else |
|
| 159 | + } else |
|
| 158 | 160 | { |
| 159 | 161 | $this->_query("SAVEPOINT SP" . $transactionLevel, $connection); |
| 160 | 162 | } |
@@ -176,8 +178,7 @@ discard block |
||
| 176 | 178 | if($point) |
| 177 | 179 | { |
| 178 | 180 | $this->_query("ROLLBACK TO SP" . $point, $connection); |
| 179 | - } |
|
| 180 | - else |
|
| 181 | + } else |
|
| 181 | 182 | { |
| 182 | 183 | @cubrid_rollback($connection); |
| 183 | 184 | } |
@@ -251,8 +252,7 @@ discard block |
||
| 251 | 252 | return false; |
| 252 | 253 | } |
| 253 | 254 | } |
| 254 | - } |
|
| 255 | - else |
|
| 255 | + } else |
|
| 256 | 256 | { |
| 257 | 257 | $bound = @cubrid_bind($req, ++$position, $value, $bind_type); |
| 258 | 258 | if(!$bound) |
@@ -343,8 +343,7 @@ discard block |
||
| 343 | 343 | if($arrayIndexEndValue) |
| 344 | 344 | { |
| 345 | 345 | $output[$arrayIndexEndValue--] = $tmp; |
| 346 | - } |
|
| 347 | - else |
|
| 346 | + } else |
|
| 348 | 347 | { |
| 349 | 348 | $output[] = $tmp; |
| 350 | 349 | } |
@@ -395,8 +394,9 @@ discard block |
||
| 395 | 394 | */ |
| 396 | 395 | function _makeSequence() |
| 397 | 396 | { |
| 398 | - if($_GLOBALS['XE_EXISTS_SEQUENCE']) |
|
| 399 | - return; |
|
| 397 | + if($_GLOBALS['XE_EXISTS_SEQUENCE']) { |
|
| 398 | + return; |
|
| 399 | + } |
|
| 400 | 400 | |
| 401 | 401 | // check cubrid serial |
| 402 | 402 | $query = sprintf('select count(*) as "count" from "db_serial" where name=\'%ssequence\'', $this->prefix); |
@@ -421,8 +421,7 @@ discard block |
||
| 421 | 421 | if($srl < 1) |
| 422 | 422 | { |
| 423 | 423 | $start = 1; |
| 424 | - } |
|
| 425 | - else |
|
| 424 | + } else |
|
| 426 | 425 | { |
| 427 | 426 | $start = $srl + 1000000; |
| 428 | 427 | } |
@@ -445,8 +444,7 @@ discard block |
||
| 445 | 444 | if($target_name == 'sequence') |
| 446 | 445 | { |
| 447 | 446 | $query = sprintf("select \"name\" from \"db_serial\" where \"name\" = '%s%s'", $this->prefix, $target_name); |
| 448 | - } |
|
| 449 | - else |
|
| 447 | + } else |
|
| 450 | 448 | { |
| 451 | 449 | $query = sprintf("select \"class_name\" from \"db_class\" where \"class_name\" = '%s%s'", $this->prefix, $target_name); |
| 452 | 450 | } |
@@ -455,8 +453,7 @@ discard block |
||
| 455 | 453 | if(cubrid_num_rows($result) > 0) |
| 456 | 454 | { |
| 457 | 455 | $output = TRUE; |
| 458 | - } |
|
| 459 | - else |
|
| 456 | + } else |
|
| 460 | 457 | { |
| 461 | 458 | $output = FALSE; |
| 462 | 459 | } |
@@ -500,8 +497,7 @@ discard block |
||
| 500 | 497 | if($size) |
| 501 | 498 | { |
| 502 | 499 | $query .= sprintf("%s(%s) ", $type, $size); |
| 503 | - } |
|
| 504 | - else |
|
| 500 | + } else |
|
| 505 | 501 | { |
| 506 | 502 | $query .= sprintf("%s ", $type); |
| 507 | 503 | } |
@@ -511,8 +507,7 @@ discard block |
||
| 511 | 507 | if($type == 'INTEGER' || $type == 'BIGINT' || $type == 'INT') |
| 512 | 508 | { |
| 513 | 509 | $query .= sprintf("default %d ", $default); |
| 514 | - } |
|
| 515 | - else |
|
| 510 | + } else |
|
| 516 | 511 | { |
| 517 | 512 | $query .= sprintf("default '%s' ", $default); |
| 518 | 513 | } |
@@ -553,8 +548,7 @@ discard block |
||
| 553 | 548 | if(cubrid_num_rows($result) > 0) |
| 554 | 549 | { |
| 555 | 550 | $output = TRUE; |
| 556 | - } |
|
| 557 | - else |
|
| 551 | + } else |
|
| 558 | 552 | { |
| 559 | 553 | $output = FALSE; |
| 560 | 554 | } |
@@ -674,8 +668,7 @@ discard block |
||
| 674 | 668 | if(!is_array($output)) |
| 675 | 669 | { |
| 676 | 670 | $indexes_to_be_deleted = array($output); |
| 677 | - } |
|
| 678 | - else |
|
| 671 | + } else |
|
| 679 | 672 | { |
| 680 | 673 | $indexes_to_be_deleted = $output; |
| 681 | 674 | } |
@@ -758,8 +751,7 @@ discard block |
||
| 758 | 751 | if(!is_array($xml_obj->table->column)) |
| 759 | 752 | { |
| 760 | 753 | $columns[] = $xml_obj->table->column; |
| 761 | - } |
|
| 762 | - else |
|
| 754 | + } else |
|
| 763 | 755 | { |
| 764 | 756 | $columns = $xml_obj->table->column; |
| 765 | 757 | } |
@@ -799,8 +791,9 @@ discard block |
||
| 799 | 791 | |
| 800 | 792 | if($type == 'varchar' || $type == 'char') |
| 801 | 793 | { |
| 802 | - if($size) |
|
| 803 | - $size = $size * 3; |
|
| 794 | + if($size) { |
|
| 795 | + $size = $size * 3; |
|
| 796 | + } |
|
| 804 | 797 | } |
| 805 | 798 | |
| 806 | 799 | |
@@ -809,12 +802,10 @@ discard block |
||
| 809 | 802 | if($primary_key) |
| 810 | 803 | { |
| 811 | 804 | $primary_list[] = $name; |
| 812 | - } |
|
| 813 | - else if($unique) |
|
| 805 | + } else if($unique) |
|
| 814 | 806 | { |
| 815 | 807 | $unique_list[$unique][] = $name; |
| 816 | - } |
|
| 817 | - else if($index) |
|
| 808 | + } else if($index) |
|
| 818 | 809 | { |
| 819 | 810 | $index_list[$index][] = $name; |
| 820 | 811 | } |
@@ -964,8 +955,7 @@ discard block |
||
| 964 | 955 | if($limit && $limit->isPageHandler()) |
| 965 | 956 | { |
| 966 | 957 | return $this->queryPageLimit($queryObject, $connection, $with_values); |
| 967 | - } |
|
| 968 | - else |
|
| 958 | + } else |
|
| 969 | 959 | { |
| 970 | 960 | $query = $this->getSelectSql($queryObject, $with_values); |
| 971 | 961 | if(is_a($query, 'BaseObject')) |
@@ -1009,8 +999,9 @@ discard block |
||
| 1009 | 999 | $buff->data = array(); |
| 1010 | 1000 | $buff->page_navigation = new PageHandler(/* $total_count */0, /* $total_page */1, /* $page */1, /* $page_count */10); //default page handler values |
| 1011 | 1001 | return $buff; |
| 1012 | - }else |
|
| 1013 | - return; |
|
| 1002 | + } else { |
|
| 1003 | + return; |
|
| 1004 | + } |
|
| 1014 | 1005 | } |
| 1015 | 1006 | |
| 1016 | 1007 | /** |
@@ -1069,8 +1060,7 @@ discard block |
||
| 1069 | 1060 | if($total_count) |
| 1070 | 1061 | { |
| 1071 | 1062 | $total_page = (int) (($total_count - 1) / $list_count) + 1; |
| 1072 | - } |
|
| 1073 | - else |
|
| 1063 | + } else |
|
| 1074 | 1064 | { |
| 1075 | 1065 | $total_page = 1; |
| 1076 | 1066 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | function __construct($path, $xml_file) |
| 83 | 83 | { |
| 84 | - if(substr($path, -1) !== '/') |
|
| 84 | + if (substr($path, -1) !== '/') |
|
| 85 | 85 | { |
| 86 | 86 | $path .= '/'; |
| 87 | 87 | } |
@@ -95,15 +95,15 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | function compile() |
| 97 | 97 | { |
| 98 | - if(!file_exists($this->xml_file)) |
|
| 98 | + if (!file_exists($this->xml_file)) |
|
| 99 | 99 | { |
| 100 | 100 | return; |
| 101 | 101 | } |
| 102 | - if(!file_exists($this->js_file)) |
|
| 102 | + if (!file_exists($this->js_file)) |
|
| 103 | 103 | { |
| 104 | 104 | $this->_compile(); |
| 105 | 105 | } |
| 106 | - else if(filemtime($this->xml_file) > filemtime($this->js_file)) |
|
| 106 | + else if (filemtime($this->xml_file) > filemtime($this->js_file)) |
|
| 107 | 107 | { |
| 108 | 108 | $this->_compile(); |
| 109 | 109 | } |
@@ -136,25 +136,25 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | |
| 138 | 138 | $field_node = $xml_obj->filter->form->node; |
| 139 | - if($field_node && !is_array($field_node)) |
|
| 139 | + if ($field_node && !is_array($field_node)) |
|
| 140 | 140 | { |
| 141 | 141 | $field_node = array($field_node); |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | $parameter_param = $xml_obj->filter->parameter->param; |
| 145 | - if($parameter_param && !is_array($parameter_param)) |
|
| 145 | + if ($parameter_param && !is_array($parameter_param)) |
|
| 146 | 146 | { |
| 147 | 147 | $parameter_param = array($parameter_param); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | $response_tag = $xml_obj->filter->response->tag; |
| 151 | - if($response_tag && !is_array($response_tag)) |
|
| 151 | + if ($response_tag && !is_array($response_tag)) |
|
| 152 | 152 | { |
| 153 | 153 | $response_tag = array($response_tag); |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | // If extend_filter exists, result returned by calling the method |
| 157 | - if($extend_filter) |
|
| 157 | + if ($extend_filter) |
|
| 158 | 158 | { |
| 159 | 159 | // If extend_filter exists, it changes the name of cache not to use cache |
| 160 | 160 | $this->js_file .= '.nocache.js'; |
@@ -163,24 +163,24 @@ discard block |
||
| 163 | 163 | list($module_name, $method) = explode('.', $extend_filter); |
| 164 | 164 | |
| 165 | 165 | // contibue if both module_name and methos exist. |
| 166 | - if($module_name && $method) |
|
| 166 | + if ($module_name && $method) |
|
| 167 | 167 | { |
| 168 | 168 | // get model object of the module |
| 169 | 169 | $oExtendFilter = getModel($module_name); |
| 170 | 170 | |
| 171 | 171 | // execute if method exists |
| 172 | - if(method_exists($oExtendFilter, $method)) |
|
| 172 | + if (method_exists($oExtendFilter, $method)) |
|
| 173 | 173 | { |
| 174 | 174 | // get the result |
| 175 | 175 | $extend_filter_list = $oExtendFilter->{$method}(TRUE); |
| 176 | 176 | $extend_filter_count = count($extend_filter_list); |
| 177 | 177 | |
| 178 | 178 | // apply lang_value from the result to the variable |
| 179 | - for($i = 0; $i < $extend_filter_count; $i++) |
|
| 179 | + for ($i = 0; $i < $extend_filter_count; $i++) |
|
| 180 | 180 | { |
| 181 | 181 | $name = $extend_filter_list[$i]->name; |
| 182 | 182 | $lang_value = $extend_filter_list[$i]->lang; |
| 183 | - if($lang_value) |
|
| 183 | + if ($lang_value) |
|
| 184 | 184 | { |
| 185 | 185 | $lang->{$name} = $lang_value; |
| 186 | 186 | } |
@@ -200,15 +200,15 @@ discard block |
||
| 200 | 200 | $fields = array(); |
| 201 | 201 | |
| 202 | 202 | // create custom rule |
| 203 | - if($rules && $rules->rule) |
|
| 203 | + if ($rules && $rules->rule) |
|
| 204 | 204 | { |
| 205 | - if(!is_array($rules->rule)) |
|
| 205 | + if (!is_array($rules->rule)) |
|
| 206 | 206 | { |
| 207 | 207 | $rules->rule = array($rules->rule); |
| 208 | 208 | } |
| 209 | - foreach($rules->rule as $r) |
|
| 209 | + foreach ($rules->rule as $r) |
|
| 210 | 210 | { |
| 211 | - if($r->attrs->type == 'regex') |
|
| 211 | + if ($r->attrs->type == 'regex') |
|
| 212 | 212 | { |
| 213 | 213 | $js_rules[] = "v.cast('ADD_RULE', ['{$r->attrs->name}', {$r->body}]);"; |
| 214 | 214 | } |
@@ -217,14 +217,14 @@ discard block |
||
| 217 | 217 | |
| 218 | 218 | // generates a field, which is a script of the checked item |
| 219 | 219 | $node_count = count($field_node); |
| 220 | - if($node_count) |
|
| 220 | + if ($node_count) |
|
| 221 | 221 | { |
| 222 | - foreach($field_node as $key => $node) |
|
| 222 | + foreach ($field_node as $key => $node) |
|
| 223 | 223 | { |
| 224 | 224 | $attrs = $node->attrs; |
| 225 | 225 | $target = trim($attrs->target); |
| 226 | 226 | |
| 227 | - if(!$target) |
|
| 227 | + if (!$target) |
|
| 228 | 228 | { |
| 229 | 229 | continue; |
| 230 | 230 | } |
@@ -234,34 +234,34 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | $field = array(); |
| 236 | 236 | |
| 237 | - if($attrs->required == 'true') |
|
| 237 | + if ($attrs->required == 'true') |
|
| 238 | 238 | { |
| 239 | 239 | $field[] = 'required:true'; |
| 240 | 240 | } |
| 241 | - if($attrs->minlength > 0) |
|
| 241 | + if ($attrs->minlength > 0) |
|
| 242 | 242 | { |
| 243 | - $field[] = 'minlength:' . $attrs->minlength; |
|
| 243 | + $field[] = 'minlength:'.$attrs->minlength; |
|
| 244 | 244 | } |
| 245 | - if($attrs->maxlength > 0) |
|
| 245 | + if ($attrs->maxlength > 0) |
|
| 246 | 246 | { |
| 247 | - $field[] = 'maxlength:' . $attrs->maxlength; |
|
| 247 | + $field[] = 'maxlength:'.$attrs->maxlength; |
|
| 248 | 248 | } |
| 249 | - if($equalto) |
|
| 249 | + if ($equalto) |
|
| 250 | 250 | { |
| 251 | 251 | $field[] = "equalto:'{$attrs->equalto}'"; |
| 252 | 252 | } |
| 253 | - if($rule) |
|
| 253 | + if ($rule) |
|
| 254 | 254 | { |
| 255 | 255 | $field[] = "rule:'{$rule}'"; |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - $fields[] = "'{$target}': {" . implode(',', $field) . "}"; |
|
| 258 | + $fields[] = "'{$target}': {".implode(',', $field)."}"; |
|
| 259 | 259 | |
| 260 | - if(!in_array($target, $target_list)) |
|
| 260 | + if (!in_array($target, $target_list)) |
|
| 261 | 261 | { |
| 262 | 262 | $target_list[] = $target; |
| 263 | 263 | } |
| 264 | - if(!$target_type_list[$target]) |
|
| 264 | + if (!$target_type_list[$target]) |
|
| 265 | 265 | { |
| 266 | 266 | $target_type_list[$target] = $filter; |
| 267 | 267 | } |
@@ -271,12 +271,12 @@ discard block |
||
| 271 | 271 | // Check extend_filter_item |
| 272 | 272 | $rule_types = array('homepage' => 'homepage', 'email_address' => 'email'); |
| 273 | 273 | |
| 274 | - for($i = 0; $i < $extend_filter_count; $i++) |
|
| 274 | + for ($i = 0; $i < $extend_filter_count; $i++) |
|
| 275 | 275 | { |
| 276 | 276 | $filter_item = $extend_filter_list[$i]; |
| 277 | 277 | $target = trim($filter_item->name); |
| 278 | 278 | |
| 279 | - if(!$target) |
|
| 279 | + if (!$target) |
|
| 280 | 280 | { |
| 281 | 281 | continue; |
| 282 | 282 | } |
@@ -287,21 +287,21 @@ discard block |
||
| 287 | 287 | $required = ($filter_item->required == 'true'); |
| 288 | 288 | |
| 289 | 289 | $field = array(); |
| 290 | - if($required) |
|
| 290 | + if ($required) |
|
| 291 | 291 | { |
| 292 | 292 | $field[] = 'required:true'; |
| 293 | 293 | } |
| 294 | - if($rule) |
|
| 294 | + if ($rule) |
|
| 295 | 295 | { |
| 296 | 296 | $field[] = "rule:'{$rule}'"; |
| 297 | 297 | } |
| 298 | - $fields[] = "\t\t'{$target}' : {" . implode(',', $field) . "}"; |
|
| 298 | + $fields[] = "\t\t'{$target}' : {".implode(',', $field)."}"; |
|
| 299 | 299 | |
| 300 | - if(!in_array($target, $target_list)) |
|
| 300 | + if (!in_array($target, $target_list)) |
|
| 301 | 301 | { |
| 302 | 302 | $target_list[] = $target; |
| 303 | 303 | } |
| 304 | - if(!$target_type_list[$target]) |
|
| 304 | + if (!$target_type_list[$target]) |
|
| 305 | 305 | { |
| 306 | 306 | $target_type_list[$target] = $type; |
| 307 | 307 | } |
@@ -310,37 +310,37 @@ discard block |
||
| 310 | 310 | // generates parameter script to create dbata |
| 311 | 311 | $rename_params = array(); |
| 312 | 312 | $parameter_count = count($parameter_param); |
| 313 | - if($parameter_count) |
|
| 313 | + if ($parameter_count) |
|
| 314 | 314 | { |
| 315 | 315 | // contains parameter of the default filter contents |
| 316 | - foreach($parameter_param as $key => $param) |
|
| 316 | + foreach ($parameter_param as $key => $param) |
|
| 317 | 317 | { |
| 318 | 318 | $attrs = $param->attrs; |
| 319 | 319 | $name = trim($attrs->name); |
| 320 | 320 | $target = trim($attrs->target); |
| 321 | 321 | |
| 322 | 322 | //if($name && $target && ($name != $target)) $js_doc[] = "\t\tparams['{$name}'] = params['{$target}']; delete params['{$target}'];"; |
| 323 | - if($name && $target && ($name != $target)) |
|
| 323 | + if ($name && $target && ($name != $target)) |
|
| 324 | 324 | { |
| 325 | 325 | $rename_params[] = "'{$target}':'{$name}'"; |
| 326 | 326 | } |
| 327 | - if($name && !in_array($name, $target_list)) |
|
| 327 | + if ($name && !in_array($name, $target_list)) |
|
| 328 | 328 | { |
| 329 | 329 | $target_list[] = $name; |
| 330 | 330 | } |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | // Check extend_filter_item |
| 334 | - for($i = 0; $i < $extend_filter_count; $i++) |
|
| 334 | + for ($i = 0; $i < $extend_filter_count; $i++) |
|
| 335 | 335 | { |
| 336 | 336 | $filter_item = $extend_filter_list[$i]; |
| 337 | 337 | $target = $name = trim($filter_item->name); |
| 338 | - if(!$name || !$target) |
|
| 338 | + if (!$name || !$target) |
|
| 339 | 339 | { |
| 340 | 340 | continue; |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - if(!in_array($name, $target_list)) |
|
| 343 | + if (!in_array($name, $target_list)) |
|
| 344 | 344 | { |
| 345 | 345 | $target_list[] = $name; |
| 346 | 346 | } |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | // generates the response script |
| 351 | 351 | $response_count = count($response_tag); |
| 352 | 352 | $responses = array(); |
| 353 | - for($i = 0; $i < $response_count; $i++) |
|
| 353 | + for ($i = 0; $i < $response_count; $i++) |
|
| 354 | 354 | { |
| 355 | 355 | $attrs = $response_tag[$i]->attrs; |
| 356 | 356 | $name = $attrs->name; |
@@ -359,10 +359,10 @@ discard block |
||
| 359 | 359 | |
| 360 | 360 | // writes lang values of the form field |
| 361 | 361 | $target_count = count($target_list); |
| 362 | - for($i = 0; $i < $target_count; $i++) |
|
| 362 | + for ($i = 0; $i < $target_count; $i++) |
|
| 363 | 363 | { |
| 364 | 364 | $target = $target_list[$i]; |
| 365 | - if(!$lang->{$target}) |
|
| 365 | + if (!$lang->{$target}) |
|
| 366 | 366 | { |
| 367 | 367 | $lang->{$target} = $target; |
| 368 | 368 | } |
@@ -381,9 +381,9 @@ discard block |
||
| 381 | 381 | */ |
| 382 | 382 | |
| 383 | 383 | // writes error messages |
| 384 | - foreach($lang->filter as $key => $val) |
|
| 384 | + foreach ($lang->filter as $key => $val) |
|
| 385 | 385 | { |
| 386 | - if(!$val) |
|
| 386 | + if (!$val) |
|
| 387 | 387 | { |
| 388 | 388 | $val = $key; |
| 389 | 389 | } |
@@ -392,24 +392,24 @@ discard block |
||
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | $callback_func = $xml_obj->filter->response->attrs->callback_func; |
| 395 | - if(!$callback_func) |
|
| 395 | + if (!$callback_func) |
|
| 396 | 396 | { |
| 397 | 397 | $callback_func = "filterAlertMessage"; |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | $confirm_msg = ''; |
| 401 | - if($confirm_msg_code) |
|
| 401 | + if ($confirm_msg_code) |
|
| 402 | 402 | { |
| 403 | 403 | $confirm_msg = $lang->{$confirm_msg_code}; |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | $jsdoc = array(); |
| 407 | - $jsdoc[] = "function {$filter_name}(form){ return legacy_filter('{$filter_name}', form, '{$module}', '{$act}', {$callback_func}, [" . implode(',', $responses) . "], '" . addslashes($confirm_msg) . "', {" . implode(',', $rename_params) . "}) };"; |
|
| 407 | + $jsdoc[] = "function {$filter_name}(form){ return legacy_filter('{$filter_name}', form, '{$module}', '{$act}', {$callback_func}, [".implode(',', $responses)."], '".addslashes($confirm_msg)."', {".implode(',', $rename_params)."}) };"; |
|
| 408 | 408 | $jsdoc[] = '(function($){'; |
| 409 | 409 | $jsdoc[] = "\tvar v=xe.getApp('validator')[0];if(!v)return false;"; |
| 410 | - $jsdoc[] = "\t" . 'v.cast("ADD_FILTER", ["' . $filter_name . '", {' . implode(',', $fields) . '}]);'; |
|
| 411 | - $jsdoc[] = "\t" . implode("\n\t", $js_rules); |
|
| 412 | - $jsdoc[] = "\t" . implode("\n\t", $js_messages); |
|
| 410 | + $jsdoc[] = "\t".'v.cast("ADD_FILTER", ["'.$filter_name.'", {'.implode(',', $fields).'}]);'; |
|
| 411 | + $jsdoc[] = "\t".implode("\n\t", $js_rules); |
|
| 412 | + $jsdoc[] = "\t".implode("\n\t", $js_messages); |
|
| 413 | 413 | $jsdoc[] = '})(jQuery);'; |
| 414 | 414 | $jsdoc = implode("\n", $jsdoc); |
| 415 | 415 | |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | */ |
| 425 | 425 | function _getCompiledFileName($xml_file) |
| 426 | 426 | { |
| 427 | - return sprintf('%s%s.%s.compiled.js', $this->compiled_path, md5($this->version . $xml_file), Context::getLangType()); |
|
| 427 | + return sprintf('%s%s.%s.compiled.js', $this->compiled_path, md5($this->version.$xml_file), Context::getLangType()); |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | } |