@@ -225,8 +225,7 @@ discard block |
||
| 225 | 225 | } |
| 226 | 226 | if (empty($this->join)){ |
| 227 | 227 | $this->join = ' ' . $type . 'JOIN' . ' ' . $table . ' ON ' . $on; |
| 228 | - } |
|
| 229 | - else{ |
|
| 228 | + } else{ |
|
| 230 | 229 | $this->join = $this->join . ' ' . $type . 'JOIN' . ' ' . $table . ' ON ' . $on; |
| 231 | 230 | } |
| 232 | 231 | return $this; |
@@ -334,8 +333,7 @@ discard block |
||
| 334 | 333 | $whereStr = ''; |
| 335 | 334 | if (is_array($where)){ |
| 336 | 335 | $whereStr = $this->getWhereStrIfIsArray($where, $type, $andOr, $escape); |
| 337 | - } |
|
| 338 | - else{ |
|
| 336 | + } else{ |
|
| 339 | 337 | if (is_array($op)){ |
| 340 | 338 | $whereStr = $this->getWhereStrIfOperatorIsArray($where, $op, $type, $escape); |
| 341 | 339 | } else { |
@@ -585,8 +583,7 @@ discard block |
||
| 585 | 583 | } |
| 586 | 584 | if (! is_null($limitEnd)){ |
| 587 | 585 | $this->limit = $limit . ', ' . $limitEnd; |
| 588 | - } |
|
| 589 | - else{ |
|
| 586 | + } else{ |
|
| 590 | 587 | $this->limit = $limit; |
| 591 | 588 | } |
| 592 | 589 | return $this; |
@@ -601,8 +598,7 @@ discard block |
||
| 601 | 598 | public function orderBy($orderBy, $orderDir = ' ASC'){ |
| 602 | 599 | if (stristr($orderBy, ' ') || $orderBy == 'rand()'){ |
| 603 | 600 | $this->orderBy = empty($this->orderBy) ? $orderBy : $this->orderBy . ', ' . $orderBy; |
| 604 | - } |
|
| 605 | - else{ |
|
| 601 | + } else{ |
|
| 606 | 602 | $this->orderBy = empty($this->orderBy) |
| 607 | 603 | ? ($orderBy . ' ' . strtoupper($orderDir)) |
| 608 | 604 | : $this->orderBy . ', ' . $orderBy . ' ' . strtoupper($orderDir); |
@@ -618,8 +614,7 @@ discard block |
||
| 618 | 614 | public function groupBy($field){ |
| 619 | 615 | if (is_array($field)){ |
| 620 | 616 | $this->groupBy = implode(', ', $field); |
| 621 | - } |
|
| 622 | - else{ |
|
| 617 | + } else{ |
|
| 623 | 618 | $this->groupBy = $field; |
| 624 | 619 | } |
| 625 | 620 | return $this; |
@@ -636,14 +631,12 @@ discard block |
||
| 636 | 631 | public function having($field, $op = null, $val = null, $escape = true){ |
| 637 | 632 | if (is_array($op)){ |
| 638 | 633 | $this->having = $this->getHavingStrIfOperatorIsArray($field, $op, $escape); |
| 639 | - } |
|
| 640 | - else if (! in_array($op, $this->operatorList)){ |
|
| 634 | + } else if (! in_array($op, $this->operatorList)){ |
|
| 641 | 635 | if (is_null($op)){ |
| 642 | 636 | $op = ''; |
| 643 | 637 | } |
| 644 | 638 | $this->having = $field . ' > ' . ($this->escape($op, $escape)); |
| 645 | - } |
|
| 646 | - else{ |
|
| 639 | + } else{ |
|
| 647 | 640 | if (is_null($val)){ |
| 648 | 641 | $val = ''; |
| 649 | 642 | } |
@@ -149,8 +149,7 @@ discard block |
||
| 149 | 149 | $isSqlSELECTQuery = stristr($this->query, 'SELECT') !== false; |
| 150 | 150 | if($isSqlSELECTQuery){ |
| 151 | 151 | $this->setResultForSelect(); |
| 152 | - } |
|
| 153 | - else{ |
|
| 152 | + } else{ |
|
| 154 | 153 | $this->setResultForNonSelect(); |
| 155 | 154 | } |
| 156 | 155 | return $this->queryResult; |
@@ -172,15 +171,13 @@ discard block |
||
| 172 | 171 | } |
| 173 | 172 | if ($this->returnAsList){ |
| 174 | 173 | $result = $this->pdoStatment->fetchAll($fetchMode); |
| 175 | - } |
|
| 176 | - else{ |
|
| 174 | + } else{ |
|
| 177 | 175 | $result = $this->pdoStatment->fetch($fetchMode); |
| 178 | 176 | } |
| 179 | 177 | //Sqlite and pgsql always return 0 when using rowCount() |
| 180 | 178 | if (in_array($this->driver, array('sqlite', 'pgsql'))){ |
| 181 | 179 | $numRows = count($result); |
| 182 | - } |
|
| 183 | - else{ |
|
| 180 | + } else{ |
|
| 184 | 181 | $numRows = $this->pdoStatment->rowCount(); |
| 185 | 182 | } |
| 186 | 183 | if(! is_object($this->queryResult)){ |
@@ -201,8 +198,7 @@ discard block |
||
| 201 | 198 | if (in_array($this->driver, array('sqlite', 'pgsql'))){ |
| 202 | 199 | $result = true; //to test the result for the query like UPDATE, INSERT, DELETE |
| 203 | 200 | $numRows = 1; //TODO use the correct method to get the exact affected row |
| 204 | - } |
|
| 205 | - else{ |
|
| 201 | + } else{ |
|
| 206 | 202 | //to test the result for the query like UPDATE, INSERT, DELETE |
| 207 | 203 | $result = $this->pdoStatment->rowCount() >= 0; |
| 208 | 204 | $numRows = $this->pdoStatment->rowCount(); |
@@ -380,8 +376,7 @@ discard block |
||
| 380 | 376 | protected function setLoggerFromParamOrCreateNewInstance(Log $logger = null){ |
| 381 | 377 | if ($logger !== null){ |
| 382 | 378 | $this->logger = $logger; |
| 383 | - } |
|
| 384 | - else{ |
|
| 379 | + } else{ |
|
| 385 | 380 | $this->logger =& class_loader('Log', 'classes'); |
| 386 | 381 | $this->logger->setLogger('Library::DatabaseQueryRunner'); |
| 387 | 382 | } |
@@ -151,8 +151,7 @@ discard block |
||
| 151 | 151 | $this->pdo->exec("SET CHARACTER SET '" . $config['charset'] . "'"); |
| 152 | 152 | $this->pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ); |
| 153 | 153 | return true; |
| 154 | - } |
|
| 155 | - catch (PDOException $e){ |
|
| 154 | + } catch (PDOException $e){ |
|
| 156 | 155 | $this->logger->fatal($e->getMessage()); |
| 157 | 156 | show_error('Cannot connect to Database.'); |
| 158 | 157 | return false; |
@@ -671,8 +670,7 @@ discard block |
||
| 671 | 670 | protected function setLoggerFromParamOrCreateNewInstance(Log $logger = null){ |
| 672 | 671 | if ($logger !== null){ |
| 673 | 672 | $this->logger = $logger; |
| 674 | - } |
|
| 675 | - else{ |
|
| 673 | + } else{ |
|
| 676 | 674 | $this->logger =& class_loader('Log', 'classes'); |
| 677 | 675 | $this->logger->setLogger('Library::Database'); |
| 678 | 676 | } |
@@ -685,8 +683,7 @@ discard block |
||
| 685 | 683 | protected function setQueryBuilderFromParamOrCreateNewInstance(DatabaseQueryBuilder $queryBuilder = null){ |
| 686 | 684 | if ($queryBuilder !== null){ |
| 687 | 685 | $this->queryBuilder = $queryBuilder; |
| 688 | - } |
|
| 689 | - else{ |
|
| 686 | + } else{ |
|
| 690 | 687 | $this->queryBuilder =& class_loader('DatabaseQueryBuilder', 'classes/database'); |
| 691 | 688 | } |
| 692 | 689 | } |
@@ -698,8 +695,7 @@ discard block |
||
| 698 | 695 | protected function setQueryRunnerFromParamOrCreateNewInstance(DatabaseQueryRunner $queryRunner = null){ |
| 699 | 696 | if ($queryRunner !== null){ |
| 700 | 697 | $this->queryRunner = $queryRunner; |
| 701 | - } |
|
| 702 | - else{ |
|
| 698 | + } else{ |
|
| 703 | 699 | $this->queryRunner =& class_loader('DatabaseQueryRunner', 'classes/database'); |
| 704 | 700 | } |
| 705 | 701 | } |
@@ -192,8 +192,7 @@ discard block |
||
| 192 | 192 | $this->logger->info('The request URI contains the front controller'); |
| 193 | 193 | array_shift($segment); |
| 194 | 194 | $this->segments = $segment; |
| 195 | - } |
|
| 196 | - else{ |
|
| 195 | + } else{ |
|
| 197 | 196 | $this->logger->info('The request URI does not contain the front controller'); |
| 198 | 197 | } |
| 199 | 198 | $uri = implode('/', $segment); |
@@ -215,8 +214,7 @@ discard block |
||
| 215 | 214 | $this->logger->info('The current request use the module [' .$moduleControllerMethod[0]. ']'); |
| 216 | 215 | $this->module = $moduleControllerMethod[0]; |
| 217 | 216 | $moduleControllerMethod = explode('@', $moduleControllerMethod[1]); |
| 218 | - } |
|
| 219 | - else{ |
|
| 217 | + } else{ |
|
| 220 | 218 | $this->logger->info('The current request does not use the module'); |
| 221 | 219 | $moduleControllerMethod = explode('@', $this->callback[$index]); |
| 222 | 220 | } |
@@ -263,8 +261,7 @@ discard block |
||
| 263 | 261 | } |
| 264 | 262 | //args |
| 265 | 263 | $this->args = $segment; |
| 266 | - } |
|
| 267 | - else{ |
|
| 264 | + } else{ |
|
| 268 | 265 | $this->logger->info('The application contains a loaded module will check if the current request is found in the module list'); |
| 269 | 266 | if(in_array($segment[0], $modules)){ |
| 270 | 267 | $this->logger->info('Found, the current request use the module [' . $segment[0] . ']'); |
@@ -278,8 +275,7 @@ discard block |
||
| 278 | 275 | if(! $path){ |
| 279 | 276 | $this->logger->info('The controller [' . $this->getController() . '] not found in the module, may be will use the module [' . $this->getModule() . '] as controller'); |
| 280 | 277 | $this->controller = $this->getModule(); |
| 281 | - } |
|
| 282 | - else{ |
|
| 278 | + } else{ |
|
| 283 | 279 | $this->controllerPath = $path; |
| 284 | 280 | array_shift($segment); |
| 285 | 281 | } |
@@ -291,8 +287,7 @@ discard block |
||
| 291 | 287 | } |
| 292 | 288 | //the remaining is for args |
| 293 | 289 | $this->args = $segment; |
| 294 | - } |
|
| 295 | - else{ |
|
| 290 | + } else{ |
|
| 296 | 291 | $this->logger->info('The current request information is not found in the module list'); |
| 297 | 292 | //controller |
| 298 | 293 | if(isset($segment[0])){ |
@@ -320,8 +315,7 @@ discard block |
||
| 320 | 315 | //if it is the module controller |
| 321 | 316 | if($this->getModule()){ |
| 322 | 317 | $this->controllerPath = Module::findControllerFullPath(ucfirst($this->getController()), $this->getModule()); |
| 323 | - } |
|
| 324 | - else{ |
|
| 318 | + } else{ |
|
| 325 | 319 | $this->controllerPath = APPS_CONTROLLER_PATH . ucfirst($this->getController()) . '.php'; |
| 326 | 320 | } |
| 327 | 321 | } |
@@ -336,15 +330,13 @@ discard block |
||
| 336 | 330 | if(! class_exists($controller, false)){ |
| 337 | 331 | $e404 = true; |
| 338 | 332 | $this->logger->info('The controller file [' .$classFilePath. '] exists but does not contain the class [' . $controller . ']'); |
| 339 | - } |
|
| 340 | - else{ |
|
| 333 | + } else{ |
|
| 341 | 334 | $controllerInstance = new $controller(); |
| 342 | 335 | $controllerMethod = $this->getMethod(); |
| 343 | 336 | if(! method_exists($controllerInstance, $controllerMethod)){ |
| 344 | 337 | $e404 = true; |
| 345 | 338 | $this->logger->info('The controller [' . $controller . '] exist but does not contain the method [' . $controllerMethod . ']'); |
| 346 | - } |
|
| 347 | - else{ |
|
| 339 | + } else{ |
|
| 348 | 340 | $this->logger->info('Routing data is set correctly now GO!'); |
| 349 | 341 | call_user_func_array(array($controllerInstance, $controllerMethod), $this->getArgs()); |
| 350 | 342 | $obj = & get_instance(); |
@@ -353,8 +345,7 @@ discard block |
||
| 353 | 345 | $obj->response->renderFinalPage(); |
| 354 | 346 | } |
| 355 | 347 | } |
| 356 | - } |
|
| 357 | - else{ |
|
| 348 | + } else{ |
|
| 358 | 349 | $this->logger->info('The controller file path [' . $classFilePath . '] does not exist'); |
| 359 | 350 | $e404 = true; |
| 360 | 351 | } |
@@ -430,8 +421,7 @@ discard block |
||
| 430 | 421 | protected function setLoggerFromParamOrCreateNewInstance(Log $logger = null){ |
| 431 | 422 | if ($logger !== null){ |
| 432 | 423 | $this->logger = $logger; |
| 433 | - } |
|
| 434 | - else{ |
|
| 424 | + } else{ |
|
| 435 | 425 | $this->logger =& class_loader('Log', 'classes'); |
| 436 | 426 | $this->logger->setLogger('Library::Router'); |
| 437 | 427 | } |
@@ -215,20 +215,15 @@ discard block |
||
| 215 | 215 | //the default value is NONE, so means no need test for NONE |
| 216 | 216 | if($level == 'fatal'){ |
| 217 | 217 | $value = self::FATAL; |
| 218 | - } |
|
| 219 | - else if($level == 'error'){ |
|
| 218 | + } else if($level == 'error'){ |
|
| 220 | 219 | $value = self::ERROR; |
| 221 | - } |
|
| 222 | - else if($level == 'warning' || $level == 'warn'){ |
|
| 220 | + } else if($level == 'warning' || $level == 'warn'){ |
|
| 223 | 221 | $value = self::WARNING; |
| 224 | - } |
|
| 225 | - else if($level == 'info'){ |
|
| 222 | + } else if($level == 'info'){ |
|
| 226 | 223 | $value = self::INFO; |
| 227 | - } |
|
| 228 | - else if($level == 'debug'){ |
|
| 224 | + } else if($level == 'debug'){ |
|
| 229 | 225 | $value = self::DEBUG; |
| 230 | - } |
|
| 231 | - else if($level == 'all'){ |
|
| 226 | + } else if($level == 'all'){ |
|
| 232 | 227 | $value = self::ALL; |
| 233 | 228 | } |
| 234 | 229 | return $value; |
@@ -245,17 +240,13 @@ discard block |
||
| 245 | 240 | //the default value is NONE, so means no need test for NONE |
| 246 | 241 | if($level == self::FATAL){ |
| 247 | 242 | $value = 'FATAL'; |
| 248 | - } |
|
| 249 | - else if($level == self::ERROR){ |
|
| 243 | + } else if($level == self::ERROR){ |
|
| 250 | 244 | $value = 'ERROR'; |
| 251 | - } |
|
| 252 | - else if($level == self::WARNING){ |
|
| 245 | + } else if($level == self::WARNING){ |
|
| 253 | 246 | $value = 'WARNING'; |
| 254 | - } |
|
| 255 | - else if($level == self::INFO){ |
|
| 247 | + } else if($level == self::INFO){ |
|
| 256 | 248 | $value = 'INFO'; |
| 257 | - } |
|
| 258 | - else if($level == self::DEBUG){ |
|
| 249 | + } else if($level == self::DEBUG){ |
|
| 259 | 250 | $value = 'DEBUG'; |
| 260 | 251 | } |
| 261 | 252 | //no need for ALL |