@@ -479,8 +479,7 @@ discard block |
||
| 479 | 479 | if (mkdir($destination_directory, 0775, true)) { |
| 480 | 480 | $this->destination_directory = $destination_directory; |
| 481 | 481 | chdir($destination_directory); |
| 482 | - } |
|
| 483 | - else{ |
|
| 482 | + } else{ |
|
| 484 | 483 | $this->logger->warning('Can not create the upload directory [' .$destination_directory. ']'); |
| 485 | 484 | } |
| 486 | 485 | } |
@@ -632,8 +631,7 @@ discard block |
||
| 632 | 631 | // set original filename if not have a new name |
| 633 | 632 | if (empty($this->filename)) { |
| 634 | 633 | $this->filename = $this->file_array[$this->input]['name']; |
| 635 | - } |
|
| 636 | - else{ |
|
| 634 | + } else{ |
|
| 637 | 635 | // Replace %s for extension in filename |
| 638 | 636 | // Before: /[\w\d]*(.[\d\w]+)$/i |
| 639 | 637 | // After: /^[\s[:alnum:]\-\_\.]*\.([\d\w]+)$/iu |
@@ -206,14 +206,12 @@ discard block |
||
| 206 | 206 | $this->pdo->exec("SET CHARACTER SET '" . $config['charset'] . "'"); |
| 207 | 207 | $this->pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ); |
| 208 | 208 | return true; |
| 209 | - } |
|
| 210 | - catch (PDOException $e){ |
|
| 209 | + } catch (PDOException $e){ |
|
| 211 | 210 | $this->logger->fatal($e->getMessage()); |
| 212 | 211 | show_error('Cannot connect to Database.'); |
| 213 | 212 | return false; |
| 214 | 213 | } |
| 215 | - } |
|
| 216 | - else{ |
|
| 214 | + } else{ |
|
| 217 | 215 | show_error('Database configuration is not set.'); |
| 218 | 216 | return false; |
| 219 | 217 | } |
@@ -231,8 +229,7 @@ discard block |
||
| 231 | 229 | $froms .= $this->prefix . $key . ', '; |
| 232 | 230 | } |
| 233 | 231 | $this->from = rtrim($froms, ', '); |
| 234 | - } |
|
| 235 | - else{ |
|
| 232 | + } else{ |
|
| 236 | 233 | $this->from = $this->prefix . $table; |
| 237 | 234 | } |
| 238 | 235 | return $this; |
@@ -338,8 +335,7 @@ discard block |
||
| 338 | 335 | } |
| 339 | 336 | if (empty($this->join)){ |
| 340 | 337 | $this->join = ' ' . $type . 'JOIN' . ' ' . $table . ' ON ' . $on; |
| 341 | - } |
|
| 342 | - else{ |
|
| 338 | + } else{ |
|
| 343 | 339 | $this->join = $this->join . ' ' . $type . 'JOIN' . ' ' . $table . ' ON ' . $on; |
| 344 | 340 | } |
| 345 | 341 | return $this; |
@@ -410,8 +406,7 @@ discard block |
||
| 410 | 406 | foreach($field as $f){ |
| 411 | 407 | $this->whereIsNull($f, $andOr); |
| 412 | 408 | } |
| 413 | - } |
|
| 414 | - else{ |
|
| 409 | + } else{ |
|
| 415 | 410 | $this->setWhereStr($field.' IS NULL ', $andOr); |
| 416 | 411 | } |
| 417 | 412 | return $this; |
@@ -428,8 +423,7 @@ discard block |
||
| 428 | 423 | foreach($field as $f){ |
| 429 | 424 | $this->whereIsNotNull($f, $andOr); |
| 430 | 425 | } |
| 431 | - } |
|
| 432 | - else{ |
|
| 426 | + } else{ |
|
| 433 | 427 | $this->setWhereStr($field.' IS NOT NULL ', $andOr); |
| 434 | 428 | } |
| 435 | 429 | return $this; |
@@ -449,8 +443,7 @@ discard block |
||
| 449 | 443 | $whereStr = ''; |
| 450 | 444 | if (is_array($where)){ |
| 451 | 445 | $whereStr = $this->getWhereStrIfIsArray($where, $type, $andOr, $escape); |
| 452 | - } |
|
| 453 | - else{ |
|
| 446 | + } else{ |
|
| 454 | 447 | if (is_array($op)){ |
| 455 | 448 | $whereStr = $this->getWhereStrIfOperatorIsArray($where, $op, $type, $escape); |
| 456 | 449 | } else { |
@@ -498,12 +491,10 @@ discard block |
||
| 498 | 491 | public function groupStart($type = '', $andOr = ' AND'){ |
| 499 | 492 | if (empty($this->where)){ |
| 500 | 493 | $this->where = $type . ' ('; |
| 501 | - } |
|
| 502 | - else{ |
|
| 494 | + } else{ |
|
| 503 | 495 | if (substr($this->where, -1) == '('){ |
| 504 | 496 | $this->where .= $type . ' ('; |
| 505 | - } |
|
| 506 | - else{ |
|
| 497 | + } else{ |
|
| 507 | 498 | $this->where .= $andOr . ' ' . $type . ' ('; |
| 508 | 499 | } |
| 509 | 500 | } |
@@ -702,8 +693,7 @@ discard block |
||
| 702 | 693 | } |
| 703 | 694 | if (! is_null($limitEnd)){ |
| 704 | 695 | $this->limit = $limit . ', ' . $limitEnd; |
| 705 | - } |
|
| 706 | - else{ |
|
| 696 | + } else{ |
|
| 707 | 697 | $this->limit = $limit; |
| 708 | 698 | } |
| 709 | 699 | return $this; |
@@ -718,8 +708,7 @@ discard block |
||
| 718 | 708 | public function orderBy($orderBy, $orderDir = ' ASC'){ |
| 719 | 709 | if (stristr($orderBy, ' ') || $orderBy == 'rand()'){ |
| 720 | 710 | $this->orderBy = empty($this->orderBy) ? $orderBy : $this->orderBy . ', ' . $orderBy; |
| 721 | - } |
|
| 722 | - else{ |
|
| 711 | + } else{ |
|
| 723 | 712 | $this->orderBy = empty($this->orderBy) ? ($orderBy . ' ' |
| 724 | 713 | . strtoupper($orderDir)) : $this->orderBy |
| 725 | 714 | . ', ' . $orderBy . ' ' . strtoupper($orderDir); |
@@ -735,8 +724,7 @@ discard block |
||
| 735 | 724 | public function groupBy($field){ |
| 736 | 725 | if (is_array($field)){ |
| 737 | 726 | $this->groupBy = implode(', ', $field); |
| 738 | - } |
|
| 739 | - else{ |
|
| 727 | + } else{ |
|
| 740 | 728 | $this->groupBy = $field; |
| 741 | 729 | } |
| 742 | 730 | return $this; |
@@ -763,14 +751,12 @@ discard block |
||
| 763 | 751 | } |
| 764 | 752 | } |
| 765 | 753 | $this->having = $w; |
| 766 | - } |
|
| 767 | - else if (! in_array($op, $this->operatorList)){ |
|
| 754 | + } else if (! in_array($op, $this->operatorList)){ |
|
| 768 | 755 | if (is_null($op)){ |
| 769 | 756 | $op = ''; |
| 770 | 757 | } |
| 771 | 758 | $this->having = $field . ' > ' . ($this->escape($op, $escape)); |
| 772 | - } |
|
| 773 | - else{ |
|
| 759 | + } else{ |
|
| 774 | 760 | if (is_null($val)){ |
| 775 | 761 | $val = ''; |
| 776 | 762 | } |
@@ -815,8 +801,7 @@ discard block |
||
| 815 | 801 | $query = $this->getAll(true); |
| 816 | 802 | if ($returnSQLQueryOrResultType === true){ |
| 817 | 803 | return $query; |
| 818 | - } |
|
| 819 | - else{ |
|
| 804 | + } else{ |
|
| 820 | 805 | return $this->query( $query, false, (($returnSQLQueryOrResultType == 'array') ? true : false) ); |
| 821 | 806 | } |
| 822 | 807 | } |
@@ -1165,8 +1150,7 @@ discard block |
||
| 1165 | 1150 | $dbCacheStatus && $isSqlSELECTQuery, |
| 1166 | 1151 | $this->temporaryCacheTtl |
| 1167 | 1152 | ); |
| 1168 | - } |
|
| 1169 | - else{ |
|
| 1153 | + } else{ |
|
| 1170 | 1154 | $this->setQueryResultForNonSelect($sqlQuery); |
| 1171 | 1155 | if (! $this->result){ |
| 1172 | 1156 | $this->setQueryError(); |
@@ -1193,8 +1177,7 @@ discard block |
||
| 1193 | 1177 | protected function setLoggerFromParamOrCreateNewInstance(Log $logger = null){ |
| 1194 | 1178 | if ($logger !== null){ |
| 1195 | 1179 | $this->logger = $logger; |
| 1196 | - } |
|
| 1197 | - else{ |
|
| 1180 | + } else{ |
|
| 1198 | 1181 | $this->logger =& class_loader('Log', 'classes'); |
| 1199 | 1182 | $this->logger->setLogger('Library::Database'); |
| 1200 | 1183 | } |
@@ -1320,8 +1303,7 @@ discard block |
||
| 1320 | 1303 | $op = ''; |
| 1321 | 1304 | } |
| 1322 | 1305 | $w = $type . $where . ' = ' . ($this->escape($op, $escape)); |
| 1323 | - } |
|
| 1324 | - else{ |
|
| 1306 | + } else{ |
|
| 1325 | 1307 | if (is_null($val)){ |
| 1326 | 1308 | $val = ''; |
| 1327 | 1309 | } |
@@ -1338,12 +1320,10 @@ discard block |
||
| 1338 | 1320 | protected function setWhereStr($whereStr, $andOr = 'AND'){ |
| 1339 | 1321 | if (empty($this->where)){ |
| 1340 | 1322 | $this->where = $whereStr; |
| 1341 | - } |
|
| 1342 | - else{ |
|
| 1323 | + } else{ |
|
| 1343 | 1324 | if (substr($this->where, -1) == '('){ |
| 1344 | 1325 | $this->where = $this->where . ' ' . $whereStr; |
| 1345 | - } |
|
| 1346 | - else{ |
|
| 1326 | + } else{ |
|
| 1347 | 1327 | $this->where = $this->where . ' '.$andOr.' ' . $whereStr; |
| 1348 | 1328 | } |
| 1349 | 1329 | } |
@@ -1421,15 +1401,13 @@ discard block |
||
| 1421 | 1401 | //if need return all result like list of record |
| 1422 | 1402 | if (is_bool($all) && $all){ |
| 1423 | 1403 | $this->result = ($array === false) ? $pdoStatment->fetchAll(PDO::FETCH_OBJ) : $pdoStatment->fetchAll(PDO::FETCH_ASSOC); |
| 1424 | - } |
|
| 1425 | - else{ |
|
| 1404 | + } else{ |
|
| 1426 | 1405 | $this->result = ($array === false) ? $pdoStatment->fetch(PDO::FETCH_OBJ) : $pdoStatment->fetch(PDO::FETCH_ASSOC); |
| 1427 | 1406 | } |
| 1428 | 1407 | //Sqlite and pgsql always return 0 when using rowCount() |
| 1429 | 1408 | if (in_array($this->config['driver'], array('sqlite', 'pgsql'))){ |
| 1430 | 1409 | $this->numRows = count($this->result); |
| 1431 | - } |
|
| 1432 | - else{ |
|
| 1410 | + } else{ |
|
| 1433 | 1411 | $this->numRows = $pdoStatment->rowCount(); |
| 1434 | 1412 | } |
| 1435 | 1413 | } |
@@ -1443,8 +1421,7 @@ discard block |
||
| 1443 | 1421 | if (in_array($this->config['driver'], array('sqlite', 'pgsql'))){ |
| 1444 | 1422 | $this->result = 1; //to test the result for the query like UPDATE, INSERT, DELETE |
| 1445 | 1423 | $this->numRows = 1; |
| 1446 | - } |
|
| 1447 | - else{ |
|
| 1424 | + } else{ |
|
| 1448 | 1425 | $this->result = $pdoStatment->rowCount() >= 0; //to test the result for the query like UPDATE, INSERT, DELETE |
| 1449 | 1426 | $this->numRows = $pdoStatment->rowCount(); |
| 1450 | 1427 | } |