@@ -10,13 +10,13 @@ |
||
| 10 | 10 | /** |
| 11 | 11 | * @param $class |
| 12 | 12 | */ |
| 13 | - function ( $class ) { |
|
| 13 | + function($class) { |
|
| 14 | 14 | |
| 15 | - $nameSpace = str_replace( '\\', '/', trim( $class, '\\' ) ) . '.php'; |
|
| 16 | - $nameSpace = str_replace( 'Qpdb/QueryBuilder/', '', $nameSpace ); |
|
| 15 | + $nameSpace = str_replace('\\', '/', trim($class, '\\')) . '.php'; |
|
| 16 | + $nameSpace = str_replace('Qpdb/QueryBuilder/', '', $nameSpace); |
|
| 17 | 17 | $includeFile = __DIR__ . '/../src/' . $nameSpace; |
| 18 | 18 | |
| 19 | - require_once( $includeFile ); |
|
| 19 | + require_once($includeFile); |
|
| 20 | 20 | |
| 21 | 21 | } |
| 22 | 22 | |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | public function defaultPriority() |
| 24 | 24 | { |
| 25 | - $this->queryStructure->setElement( QueryStructure::PRIORITY, '' ); |
|
| 25 | + $this->queryStructure->setElement(QueryStructure::PRIORITY, ''); |
|
| 26 | 26 | |
| 27 | 27 | return $this; |
| 28 | 28 | } |
@@ -23,9 +23,9 @@ discard block |
||
| 23 | 23 | * @param null $onRight |
| 24 | 24 | * @return $this |
| 25 | 25 | */ |
| 26 | - public function innerJoin( $tableJoin, $onLeft, $onRight = null ) |
|
| 26 | + public function innerJoin($tableJoin, $onLeft, $onRight = null) |
|
| 27 | 27 | { |
| 28 | - return $this->makeJoin( 'INNER JOIN', $tableJoin, $onLeft, $onRight ); |
|
| 28 | + return $this->makeJoin('INNER JOIN', $tableJoin, $onLeft, $onRight); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -34,9 +34,9 @@ discard block |
||
| 34 | 34 | * @param null $onRight |
| 35 | 35 | * @return $this |
| 36 | 36 | */ |
| 37 | - public function leftJoin( $tableJoin, $onLeft, $onRight = null ) |
|
| 37 | + public function leftJoin($tableJoin, $onLeft, $onRight = null) |
|
| 38 | 38 | { |
| 39 | - return $this->makeJoin( 'LEFT JOIN', $tableJoin, $onLeft, $onRight ); |
|
| 39 | + return $this->makeJoin('LEFT JOIN', $tableJoin, $onLeft, $onRight); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -45,9 +45,9 @@ discard block |
||
| 45 | 45 | * @param null $onRight |
| 46 | 46 | * @return $this |
| 47 | 47 | */ |
| 48 | - public function leftOuterJoin( $tableJoin, $onLeft, $onRight = null ) |
|
| 48 | + public function leftOuterJoin($tableJoin, $onLeft, $onRight = null) |
|
| 49 | 49 | { |
| 50 | - return $this->makeJoin( 'LEFT OUTER JOIN', $tableJoin, $onLeft, $onRight ); |
|
| 50 | + return $this->makeJoin('LEFT OUTER JOIN', $tableJoin, $onLeft, $onRight); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -56,9 +56,9 @@ discard block |
||
| 56 | 56 | * @param null $onRight |
| 57 | 57 | * @return $this |
| 58 | 58 | */ |
| 59 | - public function rightJoin( $tableJoin, $onLeft, $onRight = null ) |
|
| 59 | + public function rightJoin($tableJoin, $onLeft, $onRight = null) |
|
| 60 | 60 | { |
| 61 | - return $this->makeJoin( 'RIGHT JOIN', $tableJoin, $onLeft, $onRight ); |
|
| 61 | + return $this->makeJoin('RIGHT JOIN', $tableJoin, $onLeft, $onRight); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -67,9 +67,9 @@ discard block |
||
| 67 | 67 | * @param null $onRight |
| 68 | 68 | * @return $this |
| 69 | 69 | */ |
| 70 | - public function rightOuterJoin( $tableJoin, $onLeft, $onRight = null ) |
|
| 70 | + public function rightOuterJoin($tableJoin, $onLeft, $onRight = null) |
|
| 71 | 71 | { |
| 72 | - return $this->makeJoin( 'RIGHT OUTER JOIN', $tableJoin, $onLeft, $onRight ); |
|
| 72 | + return $this->makeJoin('RIGHT OUTER JOIN', $tableJoin, $onLeft, $onRight); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -78,9 +78,9 @@ discard block |
||
| 78 | 78 | * @param null $onRight |
| 79 | 79 | * @return $this |
| 80 | 80 | */ |
| 81 | - public function fullJoin( $tableJoin, $onLeft, $onRight = null ) |
|
| 81 | + public function fullJoin($tableJoin, $onLeft, $onRight = null) |
|
| 82 | 82 | { |
| 83 | - return $this->makeJoin( 'FULL JOIN', $tableJoin, $onLeft, $onRight ); |
|
| 83 | + return $this->makeJoin('FULL JOIN', $tableJoin, $onLeft, $onRight); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -89,18 +89,18 @@ discard block |
||
| 89 | 89 | * @param null $onRight |
| 90 | 90 | * @return $this |
| 91 | 91 | */ |
| 92 | - public function fullOuterJoin( $tableJoin, $onLeft, $onRight = null ) |
|
| 92 | + public function fullOuterJoin($tableJoin, $onLeft, $onRight = null) |
|
| 93 | 93 | { |
| 94 | - return $this->makeJoin( 'FULL OUTER JOIN', $tableJoin, $onLeft, $onRight ); |
|
| 94 | + return $this->makeJoin('FULL OUTER JOIN', $tableJoin, $onLeft, $onRight); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
| 98 | 98 | * @param $stringJoin |
| 99 | 99 | * @return $this |
| 100 | 100 | */ |
| 101 | - public function join( $stringJoin ) |
|
| 101 | + public function join($stringJoin) |
|
| 102 | 102 | { |
| 103 | - $this->queryStructure->setElement( QueryStructure::JOIN, $stringJoin ); |
|
| 103 | + $this->queryStructure->setElement(QueryStructure::JOIN, $stringJoin); |
|
| 104 | 104 | |
| 105 | 105 | return $this; |
| 106 | 106 | } |
@@ -112,16 +112,16 @@ discard block |
||
| 112 | 112 | * @param null $onRight |
| 113 | 113 | * @return $this |
| 114 | 114 | */ |
| 115 | - private function makeJoin( $typeJoin, $tableJoin, $onLeft, $onRight = null ) |
|
| 115 | + private function makeJoin($typeJoin, $tableJoin, $onLeft, $onRight = null) |
|
| 116 | 116 | { |
| 117 | 117 | $join = $typeJoin . ' ' . $tableJoin; |
| 118 | 118 | |
| 119 | - if ( is_null( $onRight ) ) |
|
| 119 | + if (is_null($onRight)) |
|
| 120 | 120 | $join .= " USING ( $onLeft )"; |
| 121 | 121 | else |
| 122 | 122 | $join .= " ON $onLeft = $onRight"; |
| 123 | 123 | |
| 124 | - $this->queryStructure->setElement( QueryStructure::JOIN, $join ); |
|
| 124 | + $this->queryStructure->setElement(QueryStructure::JOIN, $join); |
|
| 125 | 125 | |
| 126 | 126 | return $this; |
| 127 | 127 | } |
@@ -131,9 +131,9 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | private function getJoinSyntax() |
| 133 | 133 | { |
| 134 | - $joinString = implode( ' ', $this->queryStructure->getElement( QueryStructure::JOIN ) ); |
|
| 134 | + $joinString = implode(' ', $this->queryStructure->getElement(QueryStructure::JOIN)); |
|
| 135 | 135 | |
| 136 | - return QueryHelper::clearMultipleSpaces( $joinString ); |
|
| 136 | + return QueryHelper::clearMultipleSpaces($joinString); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | } |
| 140 | 140 | \ No newline at end of file |
@@ -116,10 +116,11 @@ |
||
| 116 | 116 | { |
| 117 | 117 | $join = $typeJoin . ' ' . $tableJoin; |
| 118 | 118 | |
| 119 | - if ( is_null( $onRight ) ) |
|
| 120 | - $join .= " USING ( $onLeft )"; |
|
| 121 | - else |
|
| 122 | - $join .= " ON $onLeft = $onRight"; |
|
| 119 | + if ( is_null( $onRight ) ) { |
|
| 120 | + $join .= " USING ( $onLeft )"; |
|
| 121 | + } else { |
|
| 122 | + $join .= " ON $onLeft = $onRight"; |
|
| 123 | + } |
|
| 123 | 124 | |
| 124 | 125 | $this->queryStructure->setElement( QueryStructure::JOIN, $join ); |
| 125 | 126 | |
@@ -24,38 +24,38 @@ |
||
| 24 | 24 | * @return $this |
| 25 | 25 | * @throws QueryException |
| 26 | 26 | */ |
| 27 | - public function limit( $limit = 0, $offset = null ) |
|
| 27 | + public function limit($limit = 0, $offset = null) |
|
| 28 | 28 | { |
| 29 | - $limit = trim( $limit ); |
|
| 29 | + $limit = trim($limit); |
|
| 30 | 30 | |
| 31 | - if ( !QueryHelper::isInteger( $limit ) ) |
|
| 32 | - throw new QueryException( 'Invalid Limit value', QueryException::QUERY_ERROR_INVALID_LIMIT ); |
|
| 31 | + if (!QueryHelper::isInteger($limit)) |
|
| 32 | + throw new QueryException('Invalid Limit value', QueryException::QUERY_ERROR_INVALID_LIMIT); |
|
| 33 | 33 | |
| 34 | - if ( $limit == 0 ) |
|
| 35 | - throw new QueryException( 'Invalid Limit zero', QueryException::QUERY_ERROR_INVALID_LIMIT_ZERO ); |
|
| 34 | + if ($limit == 0) |
|
| 35 | + throw new QueryException('Invalid Limit zero', QueryException::QUERY_ERROR_INVALID_LIMIT_ZERO); |
|
| 36 | 36 | |
| 37 | - if ( is_null( $offset ) ) { |
|
| 38 | - $this->queryStructure->setElement( QueryStructure::LIMIT, $limit ); |
|
| 37 | + if (is_null($offset)) { |
|
| 38 | + $this->queryStructure->setElement(QueryStructure::LIMIT, $limit); |
|
| 39 | 39 | |
| 40 | 40 | return $this; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - $offset = trim( $offset ); |
|
| 43 | + $offset = trim($offset); |
|
| 44 | 44 | |
| 45 | - if ( !QueryHelper::isInteger( $offset ) ) |
|
| 46 | - throw new QueryException( 'Invalid Limit offset', QueryException::QUERY_ERROR_INVALID_LIMIT_OFFSET ); |
|
| 45 | + if (!QueryHelper::isInteger($offset)) |
|
| 46 | + throw new QueryException('Invalid Limit offset', QueryException::QUERY_ERROR_INVALID_LIMIT_OFFSET); |
|
| 47 | 47 | |
| 48 | - $this->queryStructure->setElement( QueryStructure::LIMIT, $offset . ',' . $limit ); |
|
| 48 | + $this->queryStructure->setElement(QueryStructure::LIMIT, $offset . ',' . $limit); |
|
| 49 | 49 | |
| 50 | 50 | return $this; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | private function getLimitSyntax() |
| 54 | 54 | { |
| 55 | - if ( !$this->queryStructure->getElement( QueryStructure::LIMIT ) ) |
|
| 55 | + if (!$this->queryStructure->getElement(QueryStructure::LIMIT)) |
|
| 56 | 56 | return ''; |
| 57 | 57 | |
| 58 | - return 'LIMIT ' . $this->queryStructure->getElement( QueryStructure::LIMIT ); |
|
| 58 | + return 'LIMIT ' . $this->queryStructure->getElement(QueryStructure::LIMIT); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | } |
@@ -28,11 +28,13 @@ discard block |
||
| 28 | 28 | { |
| 29 | 29 | $limit = trim( $limit ); |
| 30 | 30 | |
| 31 | - if ( !QueryHelper::isInteger( $limit ) ) |
|
| 32 | - throw new QueryException( 'Invalid Limit value', QueryException::QUERY_ERROR_INVALID_LIMIT ); |
|
| 31 | + if ( !QueryHelper::isInteger( $limit ) ) { |
|
| 32 | + throw new QueryException( 'Invalid Limit value', QueryException::QUERY_ERROR_INVALID_LIMIT ); |
|
| 33 | + } |
|
| 33 | 34 | |
| 34 | - if ( $limit == 0 ) |
|
| 35 | - throw new QueryException( 'Invalid Limit zero', QueryException::QUERY_ERROR_INVALID_LIMIT_ZERO ); |
|
| 35 | + if ( $limit == 0 ) { |
|
| 36 | + throw new QueryException( 'Invalid Limit zero', QueryException::QUERY_ERROR_INVALID_LIMIT_ZERO ); |
|
| 37 | + } |
|
| 36 | 38 | |
| 37 | 39 | if ( is_null( $offset ) ) { |
| 38 | 40 | $this->queryStructure->setElement( QueryStructure::LIMIT, $limit ); |
@@ -42,8 +44,9 @@ discard block |
||
| 42 | 44 | |
| 43 | 45 | $offset = trim( $offset ); |
| 44 | 46 | |
| 45 | - if ( !QueryHelper::isInteger( $offset ) ) |
|
| 46 | - throw new QueryException( 'Invalid Limit offset', QueryException::QUERY_ERROR_INVALID_LIMIT_OFFSET ); |
|
| 47 | + if ( !QueryHelper::isInteger( $offset ) ) { |
|
| 48 | + throw new QueryException( 'Invalid Limit offset', QueryException::QUERY_ERROR_INVALID_LIMIT_OFFSET ); |
|
| 49 | + } |
|
| 47 | 50 | |
| 48 | 51 | $this->queryStructure->setElement( QueryStructure::LIMIT, $offset . ',' . $limit ); |
| 49 | 52 | |
@@ -52,8 +55,9 @@ discard block |
||
| 52 | 55 | |
| 53 | 56 | private function getLimitSyntax() |
| 54 | 57 | { |
| 55 | - if ( !$this->queryStructure->getElement( QueryStructure::LIMIT ) ) |
|
| 56 | - return ''; |
|
| 58 | + if ( !$this->queryStructure->getElement( QueryStructure::LIMIT ) ) { |
|
| 59 | + return ''; |
|
| 60 | + } |
|
| 57 | 61 | |
| 58 | 62 | return 'LIMIT ' . $this->queryStructure->getElement( QueryStructure::LIMIT ); |
| 59 | 63 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | protected function getExplainSyntax() |
| 30 | 30 | { |
| 31 | - if($this->queryStructure->getElement(QueryStructure::EXPLAIN)) |
|
| 31 | + if ($this->queryStructure->getElement(QueryStructure::EXPLAIN)) |
|
| 32 | 32 | return 'EXPLAIN'; |
| 33 | 33 | |
| 34 | 34 | return ''; |
@@ -39,9 +39,9 @@ discard block |
||
| 39 | 39 | * @param string $comment |
| 40 | 40 | * @return $this |
| 41 | 41 | */ |
| 42 | - public function withComment( $comment = '' ) |
|
| 42 | + public function withComment($comment = '') |
|
| 43 | 43 | { |
| 44 | - $this->queryStructure->setElement( QueryStructure::QUERY_COMMENT, $comment ); |
|
| 44 | + $this->queryStructure->setElement(QueryStructure::QUERY_COMMENT, $comment); |
|
| 45 | 45 | |
| 46 | 46 | return $this; |
| 47 | 47 | } |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | * @param string $identifier |
| 51 | 51 | * @return $this |
| 52 | 52 | */ |
| 53 | - public function withLogIdentifier( $identifier = null ) |
|
| 53 | + public function withLogIdentifier($identifier = null) |
|
| 54 | 54 | { |
| 55 | - $this->queryStructure->setElement( QueryStructure::QUERY_IDENTIFIER, $identifier ); |
|
| 55 | + $this->queryStructure->setElement(QueryStructure::QUERY_IDENTIFIER, $identifier); |
|
| 56 | 56 | |
| 57 | 57 | return $this; |
| 58 | 58 | } |
@@ -28,8 +28,9 @@ |
||
| 28 | 28 | |
| 29 | 29 | protected function getExplainSyntax() |
| 30 | 30 | { |
| 31 | - if($this->queryStructure->getElement(QueryStructure::EXPLAIN)) |
|
| 32 | - return 'EXPLAIN'; |
|
| 31 | + if($this->queryStructure->getElement(QueryStructure::EXPLAIN)) { |
|
| 32 | + return 'EXPLAIN'; |
|
| 33 | + } |
|
| 33 | 34 | |
| 34 | 35 | return ''; |
| 35 | 36 | } |
@@ -14,12 +14,12 @@ |
||
| 14 | 14 | |
| 15 | 15 | use Objects; |
| 16 | 16 | |
| 17 | - protected function validateColumn( $columnName, array $allowed ) |
|
| 17 | + protected function validateColumn($columnName, array $allowed) |
|
| 18 | 18 | { |
| 19 | - if ( is_integer( $columnName ) ) |
|
| 19 | + if (is_integer($columnName)) |
|
| 20 | 20 | return true; |
| 21 | 21 | |
| 22 | - if ( !count( $allowed ) ) |
|
| 22 | + if (!count($allowed)) |
|
| 23 | 23 | return true; |
| 24 | 24 | |
| 25 | 25 | return false; |
@@ -16,11 +16,13 @@ |
||
| 16 | 16 | |
| 17 | 17 | protected function validateColumn( $columnName, array $allowed ) |
| 18 | 18 | { |
| 19 | - if ( is_integer( $columnName ) ) |
|
| 20 | - return true; |
|
| 19 | + if ( is_integer( $columnName ) ) { |
|
| 20 | + return true; |
|
| 21 | + } |
|
| 21 | 22 | |
| 22 | - if ( !count( $allowed ) ) |
|
| 23 | - return true; |
|
| 23 | + if ( !count( $allowed ) ) { |
|
| 24 | + return true; |
|
| 25 | + } |
|
| 24 | 26 | |
| 25 | 27 | return false; |
| 26 | 28 | } |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | public function highPriority() |
| 23 | 23 | { |
| 24 | - $this->queryStructure->setElement( QueryStructure::PRIORITY, 'HIGH_PRIORITY' ); |
|
| 24 | + $this->queryStructure->setElement(QueryStructure::PRIORITY, 'HIGH_PRIORITY'); |
|
| 25 | 25 | |
| 26 | 26 | return $this; |
| 27 | 27 | } |
@@ -23,30 +23,30 @@ |
||
| 23 | 23 | * @param int $withReplacement |
| 24 | 24 | * @return mixed|string |
| 25 | 25 | */ |
| 26 | - private function getSyntaxReplace( $syntax, $withReplacement = QueryStatementInterface::REPLACEMENT_NONE ) |
|
| 26 | + private function getSyntaxReplace($syntax, $withReplacement = QueryStatementInterface::REPLACEMENT_NONE) |
|
| 27 | 27 | { |
| 28 | - $syntax = QueryHelper::clearMultipleSpaces( $syntax ); |
|
| 28 | + $syntax = QueryHelper::clearMultipleSpaces($syntax); |
|
| 29 | 29 | |
| 30 | - if ( !$withReplacement ) |
|
| 30 | + if (!$withReplacement) |
|
| 31 | 31 | return $syntax; |
| 32 | 32 | |
| 33 | - return $this->replaceValues( $syntax ); |
|
| 33 | + return $this->replaceValues($syntax); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * @param $syntax |
| 38 | 38 | * @return string |
| 39 | 39 | */ |
| 40 | - private function replaceValues( $syntax ) |
|
| 40 | + private function replaceValues($syntax) |
|
| 41 | 41 | { |
| 42 | - $bindParams = $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ); |
|
| 42 | + $bindParams = $this->queryStructure->getElement(QueryStructure::BIND_PARAMS); |
|
| 43 | 43 | $search = array(); |
| 44 | 44 | $replace = array(); |
| 45 | - foreach ( $bindParams as $key => $value ) { |
|
| 45 | + foreach ($bindParams as $key => $value) { |
|
| 46 | 46 | $search[] = ':' . $key; |
| 47 | - $replace[] = DbConnect::getInstance()->quote( $value ); |
|
| 47 | + $replace[] = DbConnect::getInstance()->quote($value); |
|
| 48 | 48 | } |
| 49 | - $syntax = str_ireplace( $search, $replace, $syntax ); |
|
| 49 | + $syntax = str_ireplace($search, $replace, $syntax); |
|
| 50 | 50 | |
| 51 | 51 | return $syntax; |
| 52 | 52 | |
@@ -27,8 +27,9 @@ |
||
| 27 | 27 | { |
| 28 | 28 | $syntax = QueryHelper::clearMultipleSpaces( $syntax ); |
| 29 | 29 | |
| 30 | - if ( !$withReplacement ) |
|
| 31 | - return $syntax; |
|
| 30 | + if ( !$withReplacement ) { |
|
| 31 | + return $syntax; |
|
| 32 | + } |
|
| 32 | 33 | |
| 33 | 34 | return $this->replaceValues( $syntax ); |
| 34 | 35 | } |
@@ -22,31 +22,31 @@ discard block |
||
| 22 | 22 | * @return $this |
| 23 | 23 | * @throws QueryException |
| 24 | 24 | */ |
| 25 | - public function fields( $fields ) |
|
| 25 | + public function fields($fields) |
|
| 26 | 26 | { |
| 27 | 27 | |
| 28 | - switch ( gettype( $fields ) ) { |
|
| 28 | + switch (gettype($fields)) { |
|
| 29 | 29 | case QueryStructure::ELEMENT_TYPE_ARRAY: |
| 30 | 30 | |
| 31 | - $fields = $this->prepareArrayFields( $fields ); |
|
| 31 | + $fields = $this->prepareArrayFields($fields); |
|
| 32 | 32 | |
| 33 | - if ( count( $fields ) ) |
|
| 34 | - $this->queryStructure->setElement( QueryStructure::FIELDS, implode( ', ', $fields ) ); |
|
| 33 | + if (count($fields)) |
|
| 34 | + $this->queryStructure->setElement(QueryStructure::FIELDS, implode(', ', $fields)); |
|
| 35 | 35 | else |
| 36 | - $this->queryStructure->setElement( QueryStructure::FIELDS, '*' ); |
|
| 36 | + $this->queryStructure->setElement(QueryStructure::FIELDS, '*'); |
|
| 37 | 37 | break; |
| 38 | 38 | |
| 39 | 39 | case QueryStructure::ELEMENT_TYPE_STRING: |
| 40 | 40 | |
| 41 | - $fields = trim( $fields ); |
|
| 42 | - if ( '' !== $fields ) |
|
| 43 | - $this->queryStructure->setElement( QueryStructure::FIELDS, $fields ); |
|
| 41 | + $fields = trim($fields); |
|
| 42 | + if ('' !== $fields) |
|
| 43 | + $this->queryStructure->setElement(QueryStructure::FIELDS, $fields); |
|
| 44 | 44 | else |
| 45 | - $this->queryStructure->setElement( QueryStructure::FIELDS, '*' ); |
|
| 45 | + $this->queryStructure->setElement(QueryStructure::FIELDS, '*'); |
|
| 46 | 46 | break; |
| 47 | 47 | |
| 48 | 48 | default: |
| 49 | - throw new QueryException( 'Invalid fields parameter type', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY ); |
|
| 49 | + throw new QueryException('Invalid fields parameter type', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY); |
|
| 50 | 50 | |
| 51 | 51 | } |
| 52 | 52 | |
@@ -58,16 +58,16 @@ discard block |
||
| 58 | 58 | * @return array |
| 59 | 59 | * @throws QueryException |
| 60 | 60 | */ |
| 61 | - private function prepareArrayFields( $fieldsArray = array() ) |
|
| 61 | + private function prepareArrayFields($fieldsArray = array()) |
|
| 62 | 62 | { |
| 63 | 63 | $prepareArray = []; |
| 64 | 64 | |
| 65 | - foreach ( $fieldsArray as $field ) { |
|
| 66 | - if ( gettype( $field ) !== QueryStructure::ELEMENT_TYPE_STRING ) |
|
| 67 | - throw new QueryException( 'Invalid select field type!', QueryException::QUERY_ERROR_SELECT_INVALID_FIELD ); |
|
| 65 | + foreach ($fieldsArray as $field) { |
|
| 66 | + if (gettype($field) !== QueryStructure::ELEMENT_TYPE_STRING) |
|
| 67 | + throw new QueryException('Invalid select field type!', QueryException::QUERY_ERROR_SELECT_INVALID_FIELD); |
|
| 68 | 68 | |
| 69 | - if ( '' !== trim( $field ) ) |
|
| 70 | - $prepareArray[] = trim( $field ); |
|
| 69 | + if ('' !== trim($field)) |
|
| 70 | + $prepareArray[] = trim($field); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | return $prepareArray; |
@@ -30,19 +30,21 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | $fields = $this->prepareArrayFields( $fields ); |
| 32 | 32 | |
| 33 | - if ( count( $fields ) ) |
|
| 34 | - $this->queryStructure->setElement( QueryStructure::FIELDS, implode( ', ', $fields ) ); |
|
| 35 | - else |
|
| 36 | - $this->queryStructure->setElement( QueryStructure::FIELDS, '*' ); |
|
| 33 | + if ( count( $fields ) ) { |
|
| 34 | + $this->queryStructure->setElement( QueryStructure::FIELDS, implode( ', ', $fields ) ); |
|
| 35 | + } else { |
|
| 36 | + $this->queryStructure->setElement( QueryStructure::FIELDS, '*' ); |
|
| 37 | + } |
|
| 37 | 38 | break; |
| 38 | 39 | |
| 39 | 40 | case QueryStructure::ELEMENT_TYPE_STRING: |
| 40 | 41 | |
| 41 | 42 | $fields = trim( $fields ); |
| 42 | - if ( '' !== $fields ) |
|
| 43 | - $this->queryStructure->setElement( QueryStructure::FIELDS, $fields ); |
|
| 44 | - else |
|
| 45 | - $this->queryStructure->setElement( QueryStructure::FIELDS, '*' ); |
|
| 43 | + if ( '' !== $fields ) { |
|
| 44 | + $this->queryStructure->setElement( QueryStructure::FIELDS, $fields ); |
|
| 45 | + } else { |
|
| 46 | + $this->queryStructure->setElement( QueryStructure::FIELDS, '*' ); |
|
| 47 | + } |
|
| 46 | 48 | break; |
| 47 | 49 | |
| 48 | 50 | default: |
@@ -63,11 +65,13 @@ discard block |
||
| 63 | 65 | $prepareArray = []; |
| 64 | 66 | |
| 65 | 67 | foreach ( $fieldsArray as $field ) { |
| 66 | - if ( gettype( $field ) !== QueryStructure::ELEMENT_TYPE_STRING ) |
|
| 67 | - throw new QueryException( 'Invalid select field type!', QueryException::QUERY_ERROR_SELECT_INVALID_FIELD ); |
|
| 68 | + if ( gettype( $field ) !== QueryStructure::ELEMENT_TYPE_STRING ) { |
|
| 69 | + throw new QueryException( 'Invalid select field type!', QueryException::QUERY_ERROR_SELECT_INVALID_FIELD ); |
|
| 70 | + } |
|
| 68 | 71 | |
| 69 | - if ( '' !== trim( $field ) ) |
|
| 70 | - $prepareArray[] = trim( $field ); |
|
| 72 | + if ( '' !== trim( $field ) ) { |
|
| 73 | + $prepareArray[] = trim( $field ); |
|
| 74 | + } |
|
| 71 | 75 | } |
| 72 | 76 | |
| 73 | 77 | return $prepareArray; |