@@ -88,7 +88,7 @@ |
||
88 | 88 | foreach ( $brutArray as $value ) { |
89 | 89 | $value = trim( $value ); |
90 | 90 | if ( '' !== $value ) |
91 | - $newArray[] = $value; |
|
91 | + $newArray[ ] = $value; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | return $newArray; |
@@ -87,8 +87,9 @@ discard block |
||
87 | 87 | $newArray = array(); |
88 | 88 | foreach ( $brutArray as $value ) { |
89 | 89 | $value = trim( $value ); |
90 | - if ( '' !== $value ) |
|
91 | - $newArray[] = $value; |
|
90 | + if ( '' !== $value ) { |
|
91 | + $newArray[] = $value; |
|
92 | + } |
|
92 | 93 | } |
93 | 94 | |
94 | 95 | return $newArray; |
@@ -138,8 +139,9 @@ discard block |
||
138 | 139 | $characters = 'abcdefghijklmnopqrstuvwxyz'; |
139 | 140 | $charactersLength = strlen( $characters ); |
140 | 141 | $randomString = ''; |
141 | - for ( $i = 0; $i < $length; $i++ ) |
|
142 | - $randomString .= $characters[ rand( 0, $charactersLength - 1 ) ]; |
|
142 | + for ( $i = 0; $i < $length; $i++ ) { |
|
143 | + $randomString .= $characters[ rand( 0, $charactersLength - 1 ) ]; |
|
144 | + } |
|
143 | 145 | |
144 | 146 | return str_shuffle( $randomString ); |
145 | 147 | } |
@@ -147,8 +149,9 @@ discard block |
||
147 | 149 | public static function limitString( $rowCount, $offset = null ) |
148 | 150 | { |
149 | 151 | $rowCount = intval( $rowCount ); |
150 | - if ( is_null( $offset ) ) |
|
151 | - return $rowCount; |
|
152 | + if ( is_null( $offset ) ) { |
|
153 | + return $rowCount; |
|
154 | + } |
|
152 | 155 | $offset = intval( $offset ); |
153 | 156 | |
154 | 157 | return "$offset, $rowCount"; |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @param string $glue |
279 | 279 | * @return $this |
280 | 280 | */ |
281 | - public function whereExpression( $whereString, array $bindParams = [], $glue = 'AND' ) |
|
281 | + public function whereExpression( $whereString, array $bindParams = [ ], $glue = 'AND' ) |
|
282 | 282 | { |
283 | 283 | $whereString = $this->queryStructure->bindParamsExpression( $whereString, $bindParams ); |
284 | 284 | |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * @param array $bindParams |
291 | 291 | * @return $this |
292 | 292 | */ |
293 | - public function orWhereExpression( $whereString, array $bindParams = [] ) |
|
293 | + public function orWhereExpression( $whereString, array $bindParams = [ ] ) |
|
294 | 294 | { |
295 | 295 | $whereString = $this->queryStructure->bindParamsExpression( $whereString, $bindParams ); |
296 | 296 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * @return $this |
25 | 25 | * @throws QueryException |
26 | 26 | */ |
27 | - public function orderBy( $column, array $allowedColumns = [] ) |
|
27 | + public function orderBy( $column, array $allowedColumns = [ ] ) |
|
28 | 28 | { |
29 | 29 | $column = trim( $column ); |
30 | 30 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @return $this |
44 | 44 | * @throws QueryException |
45 | 45 | */ |
46 | - public function orderByDesc( $column, array $allowedColumns = [] ) |
|
46 | + public function orderByDesc( $column, array $allowedColumns = [ ] ) |
|
47 | 47 | { |
48 | 48 | $column = trim( $column ); |
49 | 49 |
@@ -28,8 +28,9 @@ discard block |
||
28 | 28 | { |
29 | 29 | $column = trim( $column ); |
30 | 30 | |
31 | - if ( !$this->validateColumn( $column, $allowedColumns ) ) |
|
32 | - throw new QueryException( 'Invalid column name in ORDER BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME ); |
|
31 | + if ( !$this->validateColumn( $column, $allowedColumns ) ) { |
|
32 | + throw new QueryException( 'Invalid column name in ORDER BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME ); |
|
33 | + } |
|
33 | 34 | |
34 | 35 | $this->queryStructure->setElement( QueryStructure::ORDER_BY, $column ); |
35 | 36 | |
@@ -47,8 +48,9 @@ discard block |
||
47 | 48 | { |
48 | 49 | $column = trim( $column ); |
49 | 50 | |
50 | - if ( !$this->validateColumn( $column, $allowedColumns ) ) |
|
51 | - throw new QueryException( 'Invalid column name in ORDER BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME ); |
|
51 | + if ( !$this->validateColumn( $column, $allowedColumns ) ) { |
|
52 | + throw new QueryException( 'Invalid column name in ORDER BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME ); |
|
53 | + } |
|
52 | 54 | |
53 | 55 | $this->queryStructure->setElement( QueryStructure::ORDER_BY, $column . ' DESC' ); |
54 | 56 | |
@@ -73,8 +75,9 @@ discard block |
||
73 | 75 | */ |
74 | 76 | private function getOrderBySyntax() |
75 | 77 | { |
76 | - if ( count( $this->queryStructure->getElement( QueryStructure::ORDER_BY ) ) ) |
|
77 | - return 'ORDER BY ' . QueryHelper::implode( $this->queryStructure->getElement( QueryStructure::ORDER_BY ), ', ' ); |
|
78 | + if ( count( $this->queryStructure->getElement( QueryStructure::ORDER_BY ) ) ) { |
|
79 | + return 'ORDER BY ' . QueryHelper::implode( $this->queryStructure->getElement( QueryStructure::ORDER_BY ), ', ' ); |
|
80 | + } |
|
78 | 81 | |
79 | 82 | return ''; |
80 | 83 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @param string $glue |
279 | 279 | * @return $this |
280 | 280 | */ |
281 | - public function havingExpression( $whereString, array $bindParams = [], $glue = 'AND' ) |
|
281 | + public function havingExpression( $whereString, array $bindParams = [ ], $glue = 'AND' ) |
|
282 | 282 | { |
283 | 283 | $whereString = $this->queryStructure->bindParamsExpression( $whereString, $bindParams ); |
284 | 284 | |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * @param array $bindParams |
291 | 291 | * @return $this |
292 | 292 | */ |
293 | - public function orHavingExpression( $whereString, array $bindParams = [] ) |
|
293 | + public function orHavingExpression( $whereString, array $bindParams = [ ] ) |
|
294 | 294 | { |
295 | 295 | $whereString = $this->queryStructure->bindParamsExpression( $whereString, $bindParams ); |
296 | 296 |
@@ -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 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | { |
119 | 119 | $pdoArray = array(); |
120 | 120 | foreach ( $value as $item ) { |
121 | - $pdoArray[] = $this->queryStructure->bindParam( 'a', $item ); |
|
121 | + $pdoArray[ ] = $this->queryStructure->bindParam( 'a', $item ); |
|
122 | 122 | } |
123 | 123 | $body = [ |
124 | 124 | $field, |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | throw new QueryException( 'Invalid where array!', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY ); |
190 | 190 | |
191 | 191 | if ( count( $param ) == 2 ) |
192 | - $param[] = '='; |
|
192 | + $param[ ] = '='; |
|
193 | 193 | |
194 | 194 | $param[ 2 ] = trim( strtoupper( $param[ 2 ] ) ); |
195 | 195 | $param[ 2 ] = QueryHelper::clearMultipleSpaces( $param[ 2 ] ); |
@@ -61,10 +61,11 @@ discard block |
||
61 | 61 | case 'IN': |
62 | 62 | case 'NOT IN': |
63 | 63 | case '!IN': |
64 | - if ( is_a( $value, QuerySelect::class ) ) |
|
65 | - return $this->inSelectObject( $field, $value, $operator, $glue, $clauseType ); |
|
66 | - elseif ( is_array( $value ) ) |
|
67 | - return $this->inArray( $field, $value, $operator, $glue, $clauseType ); |
|
64 | + if ( is_a( $value, QuerySelect::class ) ) { |
|
65 | + return $this->inSelectObject( $field, $value, $operator, $glue, $clauseType ); |
|
66 | + } elseif ( is_array( $value ) ) { |
|
67 | + return $this->inArray( $field, $value, $operator, $glue, $clauseType ); |
|
68 | + } |
|
68 | 69 | break; |
69 | 70 | |
70 | 71 | default: |
@@ -155,8 +156,9 @@ discard block |
||
155 | 156 | */ |
156 | 157 | private function getWhereAndHavingSyntax( $clauseType ) |
157 | 158 | { |
158 | - if ( count( $this->queryStructure->getElement( $clauseType ) ) == 0 ) |
|
159 | - return ''; |
|
159 | + if ( count( $this->queryStructure->getElement( $clauseType ) ) == 0 ) { |
|
160 | + return ''; |
|
161 | + } |
|
160 | 162 | |
161 | 163 | $where = ''; |
162 | 164 | $last_type = 'where_start'; |
@@ -185,11 +187,13 @@ discard block |
||
185 | 187 | */ |
186 | 188 | private function validateWhereParam( $param ) |
187 | 189 | { |
188 | - if ( count( $param ) < 2 ) |
|
189 | - throw new QueryException( 'Invalid where array!', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY ); |
|
190 | + if ( count( $param ) < 2 ) { |
|
191 | + throw new QueryException( 'Invalid where array!', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY ); |
|
192 | + } |
|
190 | 193 | |
191 | - if ( count( $param ) == 2 ) |
|
192 | - $param[] = '='; |
|
194 | + if ( count( $param ) == 2 ) { |
|
195 | + $param[] = '='; |
|
196 | + } |
|
193 | 197 | |
194 | 198 | $param[ 2 ] = trim( strtoupper( $param[ 2 ] ) ); |
195 | 199 | $param[ 2 ] = QueryHelper::clearMultipleSpaces( $param[ 2 ] ); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | /** |
48 | 48 | * @var array |
49 | 49 | */ |
50 | - private $parameters = []; |
|
50 | + private $parameters = [ ]; |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @var string; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $column = null; |
102 | 102 | |
103 | 103 | foreach ( $Columns as $cells ) { |
104 | - $column[] = $cells[ 0 ]; |
|
104 | + $column[ ] = $cells[ 0 ]; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | return $column; |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * @param array $parameters |
177 | 177 | * @throws DbException |
178 | 178 | */ |
179 | - private function queryInit( $query, $parameters = [] ) |
|
179 | + private function queryInit( $query, $parameters = [ ] ) |
|
180 | 180 | { |
181 | 181 | $this->lastStatement = self::getQueryStatement( $query ); |
182 | 182 | $this->pdo = DbConnect::getInstance()->getConnection( $this->lastStatement ); |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | $this->bindMore( $parameters ); |
197 | 197 | else |
198 | 198 | foreach ( $parameters as $key => $val ) |
199 | - $this->parameters[] = array( $key + 1, $val ); |
|
199 | + $this->parameters[ ] = array( $key + 1, $val ); |
|
200 | 200 | |
201 | 201 | if ( count( $this->parameters ) ) { |
202 | 202 | foreach ( $this->parameters as $param => $value ) { |
@@ -93,8 +93,9 @@ discard block |
||
93 | 93 | { |
94 | 94 | $this->queryInit( $query, $params ); |
95 | 95 | |
96 | - if ( $this->lastStatement === self::QUERY_TYPE_EXPLAIN ) |
|
97 | - return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC ); |
|
96 | + if ( $this->lastStatement === self::QUERY_TYPE_EXPLAIN ) { |
|
97 | + return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC ); |
|
98 | + } |
|
98 | 99 | |
99 | 100 | $Columns = $this->sQuery->fetchAll( \PDO::FETCH_NUM ); |
100 | 101 | |
@@ -117,8 +118,9 @@ discard block |
||
117 | 118 | { |
118 | 119 | $this->queryInit( $query, $params ); |
119 | 120 | |
120 | - if ( $this->lastStatement === self::QUERY_TYPE_EXPLAIN ) |
|
121 | - return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC ); |
|
121 | + if ( $this->lastStatement === self::QUERY_TYPE_EXPLAIN ) { |
|
122 | + return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC ); |
|
123 | + } |
|
122 | 124 | |
123 | 125 | $result = $this->sQuery->fetch( $fetchmode ); |
124 | 126 | $this->sQuery->closeCursor(); // Frees up the connection to the server so that other SQL statements may be issued, |
@@ -135,8 +137,9 @@ discard block |
||
135 | 137 | { |
136 | 138 | $this->queryInit( $query, $params ); |
137 | 139 | |
138 | - if ( $this->lastStatement === self::QUERY_TYPE_EXPLAIN ) |
|
139 | - return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC ); |
|
140 | + if ( $this->lastStatement === self::QUERY_TYPE_EXPLAIN ) { |
|
141 | + return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC ); |
|
142 | + } |
|
140 | 143 | |
141 | 144 | $result = $this->sQuery->fetchColumn(); |
142 | 145 | $this->sQuery->closeCursor(); // Frees up the connection to the server so that other SQL statements may be issued |
@@ -192,24 +195,22 @@ discard block |
||
192 | 195 | /** |
193 | 196 | * Add parameters to the parameter array |
194 | 197 | */ |
195 | - if ( self::isArrayAssoc( $parameters ) ) |
|
196 | - $this->bindMore( $parameters ); |
|
197 | - else |
|
198 | - foreach ( $parameters as $key => $val ) |
|
198 | + if ( self::isArrayAssoc( $parameters ) ) { |
|
199 | + $this->bindMore( $parameters ); |
|
200 | + } else { |
|
201 | + foreach ( $parameters as $key => $val ) |
|
199 | 202 | $this->parameters[] = array( $key + 1, $val ); |
203 | + } |
|
200 | 204 | |
201 | 205 | if ( count( $this->parameters ) ) { |
202 | 206 | foreach ( $this->parameters as $param => $value ) { |
203 | 207 | if ( is_int( $value[ 1 ] ) ) { |
204 | 208 | $type = \PDO::PARAM_INT; |
205 | - } |
|
206 | - elseif ( is_bool( $value[ 1 ] ) ) { |
|
209 | + } elseif ( is_bool( $value[ 1 ] ) ) { |
|
207 | 210 | $type = \PDO::PARAM_BOOL; |
208 | - } |
|
209 | - elseif ( is_null( $value[ 1 ] ) ) { |
|
211 | + } elseif ( is_null( $value[ 1 ] ) ) { |
|
210 | 212 | $type = \PDO::PARAM_NULL; |
211 | - } |
|
212 | - else { |
|
213 | + } else { |
|
213 | 214 | $type = \PDO::PARAM_STR; |
214 | 215 | } |
215 | 216 | $this->sQuery->bindValue( $value[ 0 ], $value[ 1 ], $type ); |
@@ -288,8 +289,7 @@ discard block |
||
288 | 289 | default: |
289 | 290 | return self::QUERY_TYPE_OTHER; |
290 | 291 | } |
291 | - } |
|
292 | - else { |
|
292 | + } else { |
|
293 | 293 | return self::QUERY_TYPE_OTHER; |
294 | 294 | } |
295 | 295 | } |
@@ -300,8 +300,9 @@ discard block |
||
300 | 300 | */ |
301 | 301 | public static function isArrayAssoc( array $arr ) |
302 | 302 | { |
303 | - if ( array() === $arr ) |
|
304 | - return false; |
|
303 | + if ( array() === $arr ) { |
|
304 | + return false; |
|
305 | + } |
|
305 | 306 | |
306 | 307 | return array_keys( $arr ) !== range( 0, count( $arr ) - 1 ); |
307 | 308 | } |