@@ -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 |
@@ -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 | } |
@@ -43,8 +43,8 @@ |
||
43 | 43 | $search = array(); |
44 | 44 | $replace = array(); |
45 | 45 | foreach ( $bindParams as $key => $value ) { |
46 | - $search[] = ':' . $key; |
|
47 | - $replace[] = DbConnect::getInstance()->quote( $value ); |
|
46 | + $search[ ] = ':' . $key; |
|
47 | + $replace[ ] = DbConnect::getInstance()->quote( $value ); |
|
48 | 48 | } |
49 | 49 | $syntax = str_ireplace( $search, $replace, $syntax ); |
50 | 50 |
@@ -29,8 +29,9 @@ discard block |
||
29 | 29 | { |
30 | 30 | $this->setFieldsList( $fieldsList ); |
31 | 31 | |
32 | - foreach ( $rowsForInsert as $row ) |
|
33 | - $this->addSingleRow( $row ); |
|
32 | + foreach ( $rowsForInsert as $row ) { |
|
33 | + $this->addSingleRow( $row ); |
|
34 | + } |
|
34 | 35 | |
35 | 36 | return $this; |
36 | 37 | } |
@@ -45,8 +46,9 @@ discard block |
||
45 | 46 | { |
46 | 47 | $this->setFieldsList( $fieldsList ); |
47 | 48 | |
48 | - foreach ( $query->getBindParams() as $key => $value ) |
|
49 | - $this->queryStructure->setParams( $key, $value ); |
|
49 | + foreach ( $query->getBindParams() as $key => $value ) { |
|
50 | + $this->queryStructure->setParams( $key, $value ); |
|
51 | + } |
|
50 | 52 | |
51 | 53 | $this->queryStructure->replaceElement( QueryStructure::SET_FIELDS, $query ); |
52 | 54 | |
@@ -59,8 +61,9 @@ discard block |
||
59 | 61 | */ |
60 | 62 | private function setFieldsList( $fieldList ) |
61 | 63 | { |
62 | - if ( !is_array( $fieldList ) ) |
|
63 | - $fieldList = QueryHelper::explode( $fieldList ); |
|
64 | + if ( !is_array( $fieldList ) ) { |
|
65 | + $fieldList = QueryHelper::explode( $fieldList ); |
|
66 | + } |
|
64 | 67 | |
65 | 68 | $this->queryStructure->replaceElement( QueryStructure::FIELDS, $fieldList ); |
66 | 69 | |
@@ -74,13 +77,15 @@ discard block |
||
74 | 77 | private function addSingleRow( array $rowValues ) |
75 | 78 | { |
76 | 79 | |
77 | - if ( $this->getNumberOfFields() !== count( $rowValues ) ) |
|
78 | - throw new QueryException( 'Ivalid number of fields.', QueryException::QUERY_ERROR_INVALID_FIELDS_COUNT ); |
|
80 | + if ( $this->getNumberOfFields() !== count( $rowValues ) ) { |
|
81 | + throw new QueryException( 'Ivalid number of fields.', QueryException::QUERY_ERROR_INVALID_FIELDS_COUNT ); |
|
82 | + } |
|
79 | 83 | |
80 | 84 | $pdoRowValues = array(); |
81 | 85 | |
82 | - foreach ( $rowValues as $value ) |
|
83 | - $pdoRowValues[] = $this->queryStructure->bindParam( 'value', $value ); |
|
86 | + foreach ( $rowValues as $value ) { |
|
87 | + $pdoRowValues[] = $this->queryStructure->bindParam( 'value', $value ); |
|
88 | + } |
|
84 | 89 | |
85 | 90 | $pdoRowValuesString = '( ' . QueryHelper::implode( $pdoRowValues, ', ' ) . ' )'; |
86 | 91 | |
@@ -94,8 +99,9 @@ discard block |
||
94 | 99 | */ |
95 | 100 | private function getInsertMultipleRowsSyntax() |
96 | 101 | { |
97 | - if ( is_a( $this->queryStructure->getElement( QueryStructure::SET_FIELDS ), QuerySelect::class ) ) |
|
98 | - return $this->getSyntaxWithSelect(); |
|
102 | + if ( is_a( $this->queryStructure->getElement( QueryStructure::SET_FIELDS ), QuerySelect::class ) ) { |
|
103 | + return $this->getSyntaxWithSelect(); |
|
104 | + } |
|
99 | 105 | |
100 | 106 | $fields = '( ' . QueryHelper::implode( $this->queryStructure->getElement( QueryStructure::FIELDS ), ', ' ) . ' )'; |
101 | 107 | $values = QueryHelper::implode( $this->queryStructure->getElement( QueryStructure::SET_FIELDS ), ', ' ); |
@@ -80,7 +80,7 @@ |
||
80 | 80 | $pdoRowValues = array(); |
81 | 81 | |
82 | 82 | foreach ( $rowValues as $value ) |
83 | - $pdoRowValues[] = $this->queryStructure->bindParam( 'value', $value ); |
|
83 | + $pdoRowValues[ ] = $this->queryStructure->bindParam( 'value', $value ); |
|
84 | 84 | |
85 | 85 | $pdoRowValuesString = '( ' . QueryHelper::implode( $pdoRowValues, ', ' ) . ' )'; |
86 | 86 |
@@ -48,8 +48,9 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function setFieldsByArray( array $updateFieldsArray ) |
50 | 50 | { |
51 | - foreach ( $updateFieldsArray as $fieldName => $fieldValue ) |
|
52 | - $this->setField( $fieldName, $fieldValue ); |
|
51 | + foreach ( $updateFieldsArray as $fieldName => $fieldValue ) { |
|
52 | + $this->setField( $fieldName, $fieldValue ); |
|
53 | + } |
|
53 | 54 | |
54 | 55 | return $this; |
55 | 56 | } |
@@ -59,8 +60,9 @@ discard block |
||
59 | 60 | */ |
60 | 61 | private function getSettingFieldsSyntax() |
61 | 62 | { |
62 | - if ( !count( $this->queryStructure->getElement( QueryStructure::SET_FIELDS ) ) ) |
|
63 | - return ''; |
|
63 | + if ( !count( $this->queryStructure->getElement( QueryStructure::SET_FIELDS ) ) ) { |
|
64 | + return ''; |
|
65 | + } |
|
64 | 66 | |
65 | 67 | return 'SET ' . implode( ', ', $this->queryStructure->getElement( QueryStructure::SET_FIELDS ) ); |
66 | 68 | } |
@@ -24,7 +24,7 @@ |
||
24 | 24 | */ |
25 | 25 | public function setField( $fieldName, $fieldValue ) |
26 | 26 | { |
27 | - $fieldName = $this->queryStructure->prepare($fieldName); |
|
27 | + $fieldName = $this->queryStructure->prepare( $fieldName ); |
|
28 | 28 | $valuePdoString = $this->queryStructure->bindParam( $fieldName, $fieldValue ); |
29 | 29 | $this->queryStructure->setElement( QueryStructure::SET_FIELDS, "$fieldName = $valuePdoString" ); |
30 | 30 |
@@ -85,8 +85,9 @@ discard block |
||
85 | 85 | { |
86 | 86 | $this->syntaxEL = $this->init(); |
87 | 87 | |
88 | - foreach ( $this->syntaxEL as $name => $value ) |
|
89 | - $this->typeEL[ $name ] = gettype( $value ); |
|
88 | + foreach ( $this->syntaxEL as $name => $value ) { |
|
89 | + $this->typeEL[ $name ] = gettype( $value ); |
|
90 | + } |
|
90 | 91 | |
91 | 92 | } |
92 | 93 | |
@@ -172,16 +173,19 @@ discard block |
||
172 | 173 | */ |
173 | 174 | public function setElement( $name, $value ) |
174 | 175 | { |
175 | - if ( !array_key_exists( $name, $this->syntaxEL ) ) |
|
176 | - throw new QueryException( 'Invalid Query property', QueryException::QUERY_ERROR_ELEMENT_NOT_FOUND ); |
|
176 | + if ( !array_key_exists( $name, $this->syntaxEL ) ) { |
|
177 | + throw new QueryException( 'Invalid Query property', QueryException::QUERY_ERROR_ELEMENT_NOT_FOUND ); |
|
178 | + } |
|
177 | 179 | |
178 | - if ( $name == self::TABLE && is_a( $value, QueryStatement::class ) ) |
|
179 | - return true; |
|
180 | + if ( $name == self::TABLE && is_a( $value, QueryStatement::class ) ) { |
|
181 | + return true; |
|
182 | + } |
|
180 | 183 | |
181 | - if ( $this->typeEL[ $name ] === self::ELEMENT_TYPE_ARRAY ) |
|
182 | - $this->syntaxEL[ $name ][] = $value; |
|
183 | - else |
|
184 | - $this->syntaxEL[ $name ] = $value; |
|
184 | + if ( $this->typeEL[ $name ] === self::ELEMENT_TYPE_ARRAY ) { |
|
185 | + $this->syntaxEL[ $name ][] = $value; |
|
186 | + } else { |
|
187 | + $this->syntaxEL[ $name ] = $value; |
|
188 | + } |
|
185 | 189 | |
186 | 190 | return true; |
187 | 191 | } |
@@ -194,8 +198,9 @@ discard block |
||
194 | 198 | */ |
195 | 199 | public function replaceElement( $elementName, $elementValue ) |
196 | 200 | { |
197 | - if ( !array_key_exists( $elementName, $this->syntaxEL ) ) |
|
198 | - throw new QueryException( 'Invalid Query property', QueryException::QUERY_ERROR_ELEMENT_NOT_FOUND ); |
|
201 | + if ( !array_key_exists( $elementName, $this->syntaxEL ) ) { |
|
202 | + throw new QueryException( 'Invalid Query property', QueryException::QUERY_ERROR_ELEMENT_NOT_FOUND ); |
|
203 | + } |
|
199 | 204 | |
200 | 205 | $this->syntaxEL[ $elementName ] = $elementValue; |
201 | 206 | } |
@@ -243,11 +248,13 @@ discard block |
||
243 | 248 | */ |
244 | 249 | public function bindParamsExpression( $expression, array $params = [], $search = '?' ) |
245 | 250 | { |
246 | - if ( !count( $params ) ) |
|
247 | - return $expression; |
|
251 | + if ( !count( $params ) ) { |
|
252 | + return $expression; |
|
253 | + } |
|
248 | 254 | |
249 | - if ( strpos( $expression, $search ) === false ) |
|
250 | - return $expression; |
|
255 | + if ( strpos( $expression, $search ) === false ) { |
|
256 | + return $expression; |
|
257 | + } |
|
251 | 258 | |
252 | 259 | $params = array_slice( $params, 0, substr_count( $expression, $search ) ); |
253 | 260 |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | /** |
61 | 61 | * @var array |
62 | 62 | */ |
63 | - private static $usedInstanceIds = []; |
|
63 | + private static $usedInstanceIds = [ ]; |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * @var array |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | while ( in_array( $instance, self::$usedInstanceIds ) ) { |
145 | 145 | $instance = QueryHelper::random( 5 ); |
146 | 146 | } |
147 | - self::$usedInstanceIds[] = $instance; |
|
147 | + self::$usedInstanceIds[ ] = $instance; |
|
148 | 148 | |
149 | 149 | return $instance; |
150 | 150 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | return true; |
192 | 192 | |
193 | 193 | if ( $this->typeEL[ $name ] === self::ELEMENT_TYPE_ARRAY ) |
194 | - $this->syntaxEL[ $name ][] = $value; |
|
194 | + $this->syntaxEL[ $name ][ ] = $value; |
|
195 | 195 | else |
196 | 196 | $this->syntaxEL[ $name ] = $value; |
197 | 197 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * @param string $search |
239 | 239 | * @return string |
240 | 240 | */ |
241 | - public function bindParamsExpression( $expression, array $params = [], $search = '?' ) |
|
241 | + public function bindParamsExpression( $expression, array $params = [ ], $search = '?' ) |
|
242 | 242 | { |
243 | 243 | if ( !count( $params ) ) |
244 | 244 | return $expression; |
@@ -249,12 +249,12 @@ discard block |
||
249 | 249 | $params = array_slice( $params, 0, substr_count( $expression, $search ) ); |
250 | 250 | |
251 | 251 | $i = 0; |
252 | - $arrayReturn = []; |
|
252 | + $arrayReturn = [ ]; |
|
253 | 253 | $expressionToArray = explode( $search, $expression ); |
254 | 254 | |
255 | 255 | foreach ( $expressionToArray as $sub ) { |
256 | - $arrayReturn[] = $sub; |
|
257 | - $arrayReturn[] = array_key_exists( $i, $params ) ? $this->bindParam( 'exp', $params[ $i ] ) : ''; |
|
256 | + $arrayReturn[ ] = $sub; |
|
257 | + $arrayReturn[ ] = array_key_exists( $i, $params ) ? $this->bindParam( 'exp', $params[ $i ] ) : ''; |
|
258 | 258 | $i++; |
259 | 259 | } |
260 | 260 |
@@ -49,7 +49,7 @@ |
||
49 | 49 | /** |
50 | 50 | * @var array |
51 | 51 | */ |
52 | - protected $usedInstanceIds = []; |
|
52 | + protected $usedInstanceIds = [ ]; |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * @var string |
@@ -49,32 +49,32 @@ |
||
49 | 49 | /** |
50 | 50 | * Explain |
51 | 51 | */ |
52 | - $syntax[] = $this->getExplainSyntax(); |
|
52 | + $syntax[ ] = $this->getExplainSyntax(); |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * UPDATE statement |
56 | 56 | */ |
57 | - $syntax[] = $this->statement; |
|
57 | + $syntax[ ] = $this->statement; |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * PRIORITY |
61 | 61 | */ |
62 | - $syntax[] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
62 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
63 | 63 | |
64 | 64 | /** |
65 | 65 | * IGNORE clause |
66 | 66 | */ |
67 | - $syntax[] = $this->queryStructure->getElement( QueryStructure::IGNORE ) ? 'IGNORE' : ''; |
|
67 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::IGNORE ) ? 'IGNORE' : ''; |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * INTO table |
71 | 71 | */ |
72 | - $syntax[] = 'INTO ' . $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
72 | + $syntax[ ] = 'INTO ' . $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
73 | 73 | |
74 | 74 | /** |
75 | 75 | * FIELDS update |
76 | 76 | */ |
77 | - $syntax[] = $this->getInsertMultipleRowsSyntax(); |
|
77 | + $syntax[ ] = $this->getInsertMultipleRowsSyntax(); |
|
78 | 78 | |
79 | 79 | $syntax = implode( ' ', $syntax ); |
80 | 80 |
@@ -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 |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | |
140 | 140 | $pdoArray = array(); |
141 | 141 | foreach ( $value as $item ) { |
142 | - $pdoArray[] = $this->queryStructure->bindParam( 'a', $item ); |
|
142 | + $pdoArray[ ] = $this->queryStructure->bindParam( 'a', $item ); |
|
143 | 143 | } |
144 | 144 | $body = [ |
145 | 145 | $field, |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | throw new QueryException( 'Invalid where array!', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY ); |
217 | 217 | |
218 | 218 | if ( count( $param ) == 2 ) |
219 | - $param[] = '='; |
|
219 | + $param[ ] = '='; |
|
220 | 220 | |
221 | 221 | $param[ 0 ] = $this->queryStructure->prepare( $param[ 0 ] ); |
222 | 222 | $param[ 2 ] = trim( strtoupper( $param[ 2 ] ) ); |
@@ -103,10 +103,11 @@ discard block |
||
103 | 103 | |
104 | 104 | private function makeInCondition() |
105 | 105 | { |
106 | - if ( is_a( $this->temporaryParam[ 1 ], QuerySelect::class ) ) |
|
107 | - $this->inQuerySelect(); |
|
108 | - elseif ( is_array( $this->temporaryParam[ 1 ] ) ) |
|
109 | - $this->inArray(); |
|
106 | + if ( is_a( $this->temporaryParam[ 1 ], QuerySelect::class ) ) { |
|
107 | + $this->inQuerySelect(); |
|
108 | + } elseif ( is_array( $this->temporaryParam[ 1 ] ) ) { |
|
109 | + $this->inArray(); |
|
110 | + } |
|
110 | 111 | } |
111 | 112 | |
112 | 113 | private function inQuerySelect() |
@@ -182,8 +183,9 @@ discard block |
||
182 | 183 | */ |
183 | 184 | private function getWhereAndHavingSyntax( $clauseType ) |
184 | 185 | { |
185 | - if ( count( $this->queryStructure->getElement( $clauseType ) ) == 0 ) |
|
186 | - return ''; |
|
186 | + if ( count( $this->queryStructure->getElement( $clauseType ) ) == 0 ) { |
|
187 | + return ''; |
|
188 | + } |
|
187 | 189 | |
188 | 190 | $where = ''; |
189 | 191 | $last_type = 'where_start'; |
@@ -212,11 +214,13 @@ discard block |
||
212 | 214 | */ |
213 | 215 | private function validateWhereParam( $param ) |
214 | 216 | { |
215 | - if ( count( $param ) < 2 ) |
|
216 | - throw new QueryException( 'Invalid where array!', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY ); |
|
217 | + if ( count( $param ) < 2 ) { |
|
218 | + throw new QueryException( 'Invalid where array!', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY ); |
|
219 | + } |
|
217 | 220 | |
218 | - if ( count( $param ) == 2 ) |
|
219 | - $param[] = '='; |
|
221 | + if ( count( $param ) == 2 ) { |
|
222 | + $param[] = '='; |
|
223 | + } |
|
220 | 224 | |
221 | 225 | $param[ 0 ] = $this->queryStructure->prepare( $param[ 0 ] ); |
222 | 226 | $param[ 2 ] = trim( strtoupper( $param[ 2 ] ) ); |