@@ -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 |
@@ -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,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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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; |
@@ -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 ), ', ' ); |
@@ -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] ); |
@@ -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 | } |