@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | /** |
36 | 36 | * @var array |
37 | 37 | */ |
38 | - protected $usedInstanceIds = []; |
|
38 | + protected $usedInstanceIds = [ ]; |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * @var string |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @return $this |
64 | 64 | * @throws \Qpdb\QueryBuilder\Dependencies\QueryException |
65 | 65 | */ |
66 | - public function withBindParams( array $params = [] ) |
|
66 | + public function withBindParams( array $params = [ ] ) |
|
67 | 67 | { |
68 | 68 | $this->queryStructure->replaceElement( QueryStructure::BIND_PARAMS, $params ); |
69 | 69 |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | * @return array |
38 | 38 | */ |
39 | 39 | public function getSyntax( $replacement = self::REPLACEMENT_NONE ) { |
40 | - $queries = []; |
|
40 | + $queries = [ ]; |
|
41 | 41 | foreach ( $this->transaction as $queryStatement ) { |
42 | - $queries[] = $queryStatement->getSyntax( $replacement ); |
|
42 | + $queries[ ] = $queryStatement->getSyntax( $replacement ); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | return $queries; |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @param array $params |
51 | 51 | * @return mixed|null |
52 | 52 | */ |
53 | - public function executeFunction( \Closure $function, array $params = [] ) { |
|
53 | + public function executeFunction( \Closure $function, array $params = [ ] ) { |
|
54 | 54 | return PdoWrapperService::getInstance()->transaction( $function, $params ); |
55 | 55 | } |
56 | 56 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @return mixed|null |
59 | 59 | */ |
60 | 60 | public function execute() { |
61 | - $transaction = (array)$this->transaction; |
|
61 | + $transaction = ( array ) $this->transaction; |
|
62 | 62 | |
63 | 63 | return PdoWrapperService::getInstance()->transaction( |
64 | 64 | function() use ( $transaction ) { |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | * @return array |
78 | 78 | */ |
79 | 79 | public function getBindParams() { |
80 | - $queries = []; |
|
80 | + $queries = [ ]; |
|
81 | 81 | foreach ( $this->transaction as $queryStatement ) { |
82 | - $queries[] = $queryStatement->getBindParams(); |
|
82 | + $queries[ ] = $queryStatement->getBindParams(); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | return $queries; |
@@ -53,37 +53,37 @@ discard block |
||
53 | 53 | /** |
54 | 54 | * Explain |
55 | 55 | */ |
56 | - $syntax[] = $this->getExplainSyntax(); |
|
56 | + $syntax[ ] = $this->getExplainSyntax(); |
|
57 | 57 | |
58 | 58 | /** |
59 | 59 | * UPDATE statement |
60 | 60 | */ |
61 | - $syntax[] = $this->statement; |
|
61 | + $syntax[ ] = $this->statement; |
|
62 | 62 | |
63 | 63 | /** |
64 | 64 | * PRIORITY |
65 | 65 | */ |
66 | - $syntax[] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
66 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * TABLE update |
70 | 70 | */ |
71 | - $syntax[] = 'FROM ' . $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
71 | + $syntax[ ] = 'FROM ' . $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
72 | 72 | |
73 | 73 | /** |
74 | 74 | * WHERE clause |
75 | 75 | */ |
76 | - $syntax[] = $this->getWhereSyntax(); |
|
76 | + $syntax[ ] = $this->getWhereSyntax(); |
|
77 | 77 | |
78 | 78 | /** |
79 | 79 | * ORDER BY clause |
80 | 80 | */ |
81 | - $syntax[] = $this->getOrderBySyntax(); |
|
81 | + $syntax[ ] = $this->getOrderBySyntax(); |
|
82 | 82 | |
83 | 83 | /** |
84 | 84 | * LIMIT clause |
85 | 85 | */ |
86 | - $syntax[] = $this->getLimitSyntax(); |
|
86 | + $syntax[ ] = $this->getLimitSyntax(); |
|
87 | 87 | |
88 | 88 | $syntax = implode( ' ', $syntax ); |
89 | 89 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | if ( $this->queryStructure->getElement( ( QueryStructure::WHERE_TRIGGER ) ) && !count( $this->queryStructure->getElement( QueryStructure::WHERE ) ) ) |
100 | 100 | throw new QueryException( 'Where clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER ); |
101 | 101 | |
102 | - return PdoWrapperService::getInstance()->query($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS))->rowCount(); |
|
102 | + return PdoWrapperService::getInstance()->query( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) )->rowCount(); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 |
@@ -96,8 +96,9 @@ |
||
96 | 96 | */ |
97 | 97 | public function execute() |
98 | 98 | { |
99 | - if ( $this->queryStructure->getElement( ( QueryStructure::WHERE_TRIGGER ) ) && !count( $this->queryStructure->getElement( QueryStructure::WHERE ) ) ) |
|
100 | - throw new QueryException( 'Where clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER ); |
|
99 | + if ( $this->queryStructure->getElement( ( QueryStructure::WHERE_TRIGGER ) ) && !count( $this->queryStructure->getElement( QueryStructure::WHERE ) ) ) { |
|
100 | + throw new QueryException( 'Where clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER ); |
|
101 | + } |
|
101 | 102 | |
102 | 103 | return PdoWrapperService::getInstance()->query($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS))->rowCount(); |
103 | 104 | } |
@@ -120,62 +120,62 @@ discard block |
||
120 | 120 | /** |
121 | 121 | * Explain |
122 | 122 | */ |
123 | - $syntax[] = $this->getExplainSyntax(); |
|
123 | + $syntax[ ] = $this->getExplainSyntax(); |
|
124 | 124 | |
125 | 125 | /** |
126 | 126 | * SELECT statement |
127 | 127 | */ |
128 | - $syntax[] = $this->statement; |
|
128 | + $syntax[ ] = $this->statement; |
|
129 | 129 | |
130 | 130 | /** |
131 | 131 | * PRIORITY |
132 | 132 | */ |
133 | - $syntax[] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
133 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
134 | 134 | |
135 | 135 | /** |
136 | 136 | * DISTINCT clause |
137 | 137 | */ |
138 | - $syntax[] = $this->getDistinctSyntax(); |
|
138 | + $syntax[ ] = $this->getDistinctSyntax(); |
|
139 | 139 | |
140 | 140 | /** |
141 | 141 | * FIELDS |
142 | 142 | */ |
143 | - $syntax[] = $this->queryStructure->getElement( QueryStructure::FIELDS ); |
|
143 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::FIELDS ); |
|
144 | 144 | |
145 | 145 | /** |
146 | 146 | * FROM table or queryStructure |
147 | 147 | */ |
148 | - $syntax[] = 'FROM ' . $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
148 | + $syntax[ ] = 'FROM ' . $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
149 | 149 | |
150 | 150 | /** |
151 | 151 | * JOIN CLAUSES |
152 | 152 | */ |
153 | - $syntax[] = $this->getJoinSyntax(); |
|
153 | + $syntax[ ] = $this->getJoinSyntax(); |
|
154 | 154 | |
155 | 155 | /** |
156 | 156 | * WHERE clause |
157 | 157 | */ |
158 | - $syntax[] = $this->getWhereSyntax(); |
|
158 | + $syntax[ ] = $this->getWhereSyntax(); |
|
159 | 159 | |
160 | 160 | /** |
161 | 161 | * GROUP BY clause |
162 | 162 | */ |
163 | - $syntax[] = $this->getGroupBySyntax(); |
|
163 | + $syntax[ ] = $this->getGroupBySyntax(); |
|
164 | 164 | |
165 | 165 | /** |
166 | 166 | * HAVING clause |
167 | 167 | */ |
168 | - $syntax[] = $this->getHavingSyntax(); |
|
168 | + $syntax[ ] = $this->getHavingSyntax(); |
|
169 | 169 | |
170 | 170 | /** |
171 | 171 | * ORDER BY clause |
172 | 172 | */ |
173 | - $syntax[] = $this->getOrderBySyntax(); |
|
173 | + $syntax[ ] = $this->getOrderBySyntax(); |
|
174 | 174 | |
175 | 175 | /** |
176 | 176 | * LIMIT clause |
177 | 177 | */ |
178 | - $syntax[] = $this->getLimitSyntax(); |
|
178 | + $syntax[ ] = $this->getLimitSyntax(); |
|
179 | 179 | |
180 | 180 | $syntax = implode( ' ', $syntax ); |
181 | 181 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | case $this->queryStructure->getElement( QueryStructure::COLUMN ): |
201 | 201 | return PdoWrapperService::getInstance()->queryFetchAll( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ), \PDO::FETCH_COLUMN ); |
202 | 202 | default: |
203 | - return PdoWrapperService::getInstance()->queryFetchAll($this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ), \PDO::FETCH_ASSOC); |
|
203 | + return PdoWrapperService::getInstance()->queryFetchAll( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ), \PDO::FETCH_ASSOC ); |
|
204 | 204 | } |
205 | 205 | } |
206 | 206 |
@@ -56,8 +56,9 @@ discard block |
||
56 | 56 | $this->queryStructure->setElement( QueryStructure::TABLE, $tableName ); |
57 | 57 | |
58 | 58 | $tableSelectParams = $table->getBindParams(); |
59 | - foreach ( $tableSelectParams as $key => $value ) |
|
60 | - $this->queryStructure->setParams( $key, $value ); |
|
59 | + foreach ( $tableSelectParams as $key => $value ) { |
|
60 | + $this->queryStructure->setParams( $key, $value ); |
|
61 | + } |
|
61 | 62 | |
62 | 63 | } |
63 | 64 | } |
@@ -112,8 +113,9 @@ discard block |
||
112 | 113 | $this->queryStructure->setElement( QueryStructure::DISTINCT, 0 ); //??? |
113 | 114 | } |
114 | 115 | |
115 | - if ( $this->queryStructure->getElement( QueryStructure::FIRST ) ) |
|
116 | - $this->queryStructure->setElement( QueryStructure::LIMIT, 1 ); |
|
116 | + if ( $this->queryStructure->getElement( QueryStructure::FIRST ) ) { |
|
117 | + $this->queryStructure->setElement( QueryStructure::LIMIT, 1 ); |
|
118 | + } |
|
117 | 119 | |
118 | 120 | $syntax = array(); |
119 | 121 |
@@ -62,32 +62,32 @@ discard block |
||
62 | 62 | /** |
63 | 63 | * Explain |
64 | 64 | */ |
65 | - $syntax[] = $this->getExplainSyntax(); |
|
65 | + $syntax[ ] = $this->getExplainSyntax(); |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * UPDATE statement |
69 | 69 | */ |
70 | - $syntax[] = $this->statement; |
|
70 | + $syntax[ ] = $this->statement; |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * PRIORITY |
74 | 74 | */ |
75 | - $syntax[] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
75 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
76 | 76 | |
77 | 77 | /** |
78 | 78 | * IGNORE clause |
79 | 79 | */ |
80 | - $syntax[] = $this->queryStructure->getElement( QueryStructure::IGNORE ) ? 'IGNORE' : ''; |
|
80 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::IGNORE ) ? 'IGNORE' : ''; |
|
81 | 81 | |
82 | 82 | /** |
83 | 83 | * INTO table |
84 | 84 | */ |
85 | - $syntax[] = 'INTO ' . $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
85 | + $syntax[ ] = 'INTO ' . $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * FIELDS update |
89 | 89 | */ |
90 | - $syntax[] = $this->getSettingFieldsSyntax(); |
|
90 | + $syntax[ ] = $this->getSettingFieldsSyntax(); |
|
91 | 91 | |
92 | 92 | $syntax = implode( ' ', $syntax ); |
93 | 93 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @return bool|mixed|\PDOStatement |
100 | 100 | */ |
101 | 101 | public function execute() { |
102 | - return PdoWrapperService::getInstance()->query($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS))->rowCount(); |
|
102 | + return PdoWrapperService::getInstance()->query( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) )->rowCount(); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 |
@@ -53,47 +53,47 @@ discard block |
||
53 | 53 | /** |
54 | 54 | * Explain |
55 | 55 | */ |
56 | - $syntax[] = $this->getExplainSyntax(); |
|
56 | + $syntax[ ] = $this->getExplainSyntax(); |
|
57 | 57 | |
58 | 58 | /** |
59 | 59 | * UPDATE statement |
60 | 60 | */ |
61 | - $syntax[] = $this->statement; |
|
61 | + $syntax[ ] = $this->statement; |
|
62 | 62 | |
63 | 63 | /** |
64 | 64 | * PRIORITY |
65 | 65 | */ |
66 | - $syntax[] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
66 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * IGNORE clause |
70 | 70 | */ |
71 | - $syntax[] = $this->queryStructure->getElement( QueryStructure::IGNORE ) ? 'IGNORE' : ''; |
|
71 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::IGNORE ) ? 'IGNORE' : ''; |
|
72 | 72 | |
73 | 73 | /** |
74 | 74 | * TABLE update |
75 | 75 | */ |
76 | - $syntax[] = $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
76 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
77 | 77 | |
78 | 78 | /** |
79 | 79 | * FIELDS update |
80 | 80 | */ |
81 | - $syntax[] = $this->getSettingFieldsSyntax(); |
|
81 | + $syntax[ ] = $this->getSettingFieldsSyntax(); |
|
82 | 82 | |
83 | 83 | /** |
84 | 84 | * WHERE clause |
85 | 85 | */ |
86 | - $syntax[] = $this->getWhereSyntax(); |
|
86 | + $syntax[ ] = $this->getWhereSyntax(); |
|
87 | 87 | |
88 | 88 | /** |
89 | 89 | * ORDER BY clause |
90 | 90 | */ |
91 | - $syntax[] = $this->getOrderBySyntax(); |
|
91 | + $syntax[ ] = $this->getOrderBySyntax(); |
|
92 | 92 | |
93 | 93 | /** |
94 | 94 | * LIMIT clause |
95 | 95 | */ |
96 | - $syntax[] = $this->getLimitSyntax(); |
|
96 | + $syntax[ ] = $this->getLimitSyntax(); |
|
97 | 97 | |
98 | 98 | $syntax = implode( ' ', $syntax ); |
99 | 99 | |
@@ -110,6 +110,6 @@ discard block |
||
110 | 110 | if ( $this->queryStructure->getElement( ( QueryStructure::WHERE_TRIGGER ) ) && !count( $this->queryStructure->getElement( QueryStructure::WHERE ) ) ) |
111 | 111 | throw new QueryException( 'Where clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER ); |
112 | 112 | |
113 | - return PdoWrapperService::getInstance()->query($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS))->rowCount(); |
|
113 | + return PdoWrapperService::getInstance()->query( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) )->rowCount(); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | \ No newline at end of file |
@@ -107,8 +107,9 @@ |
||
107 | 107 | */ |
108 | 108 | public function execute() |
109 | 109 | { |
110 | - if ( $this->queryStructure->getElement( ( QueryStructure::WHERE_TRIGGER ) ) && !count( $this->queryStructure->getElement( QueryStructure::WHERE ) ) ) |
|
111 | - throw new QueryException( 'Where clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER ); |
|
110 | + if ( $this->queryStructure->getElement( ( QueryStructure::WHERE_TRIGGER ) ) && !count( $this->queryStructure->getElement( QueryStructure::WHERE ) ) ) { |
|
111 | + throw new QueryException( 'Where clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER ); |
|
112 | + } |
|
112 | 113 | |
113 | 114 | return PdoWrapperService::getInstance()->query($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS))->rowCount(); |
114 | 115 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $this->setTable(); |
45 | 45 | $this->setPrimaryKey(); |
46 | 46 | $this->setOrderField(); |
47 | - $this->primary = (array)$this->primary; |
|
47 | + $this->primary = ( array ) $this->primary; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @return array|bool |
54 | 54 | * @throws QueryException |
55 | 55 | */ |
56 | - public function getRowById( $id, array $fields = [] ) |
|
56 | + public function getRowById( $id, array $fields = [ ] ) |
|
57 | 57 | { |
58 | 58 | $conditions = $this->getPrimaryKeyConditions( $id ); |
59 | 59 | $result = QueryBuild::select( $this->table )->fields( $fields ); |
@@ -119,14 +119,14 @@ discard block |
||
119 | 119 | throw new QueryException( 'Order field is not defined' ); |
120 | 120 | |
121 | 121 | $query = /** @lang text */ |
122 | - "UPDATE `{$this->table}` SET `{$this->orderField}` = CASE `{$this->primary[0]}` \r\n"; |
|
122 | + "UPDATE `{$this->table}` SET `{$this->orderField}` = CASE `{$this->primary[ 0 ]}` \r\n"; |
|
123 | 123 | foreach ( $updates_ord as $position => $id ) { |
124 | 124 | $pos = $position + 1; |
125 | 125 | $query .= " WHEN '$id' THEN '$pos' \r\n"; |
126 | 126 | } |
127 | 127 | $query .= "ELSE `{$this->orderField}` END"; |
128 | 128 | |
129 | - return PdoWrapperService::getInstance()->query($query, []); |
|
129 | + return PdoWrapperService::getInstance()->query( $query, [ ] ); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | if ( count( $this->primary ) !== count( $id ) ) |
144 | 144 | throw new QueryException( 'Invalid primary key', QueryException::QUERY_CRUD_INVALID_PRIMARY ); |
145 | 145 | |
146 | - $conditions = []; |
|
146 | + $conditions = [ ]; |
|
147 | 147 | |
148 | 148 | foreach ( $this->primary as $index => $key ) |
149 | 149 | $conditions[ $key ] = $id[ $index ]; |
@@ -57,8 +57,9 @@ discard block |
||
57 | 57 | { |
58 | 58 | $conditions = $this->getPrimaryKeyConditions( $id ); |
59 | 59 | $result = QueryBuild::select( $this->table )->fields( $fields ); |
60 | - foreach ( $conditions as $field => $value ) |
|
61 | - $result->whereEqual( $field, $value ); |
|
60 | + foreach ( $conditions as $field => $value ) { |
|
61 | + $result->whereEqual( $field, $value ); |
|
62 | + } |
|
62 | 63 | |
63 | 64 | return $result->first()->execute(); |
64 | 65 | } |
@@ -73,8 +74,9 @@ discard block |
||
73 | 74 | { |
74 | 75 | $conditions = $this->getPrimaryKeyConditions( $id ); |
75 | 76 | $result = QueryBuild::delete( $this->table ); |
76 | - foreach ( $conditions as $field => $value ) |
|
77 | - $result->whereEqual( $field, $value ); |
|
77 | + foreach ( $conditions as $field => $value ) { |
|
78 | + $result->whereEqual( $field, $value ); |
|
79 | + } |
|
78 | 80 | |
79 | 81 | return $result->execute(); |
80 | 82 | } |
@@ -89,8 +91,9 @@ discard block |
||
89 | 91 | { |
90 | 92 | $conditions = $this->getPrimaryKeyConditions( $id ); |
91 | 93 | $result = QueryBuild::update( $this->table ); |
92 | - foreach ( $conditions as $field => $value ) |
|
93 | - $result->whereEqual( $field, $value ); |
|
94 | + foreach ( $conditions as $field => $value ) { |
|
95 | + $result->whereEqual( $field, $value ); |
|
96 | + } |
|
94 | 97 | $result->setFieldsByArray( $arrayUpdater ); |
95 | 98 | |
96 | 99 | return $result->execute(); |
@@ -115,8 +118,9 @@ discard block |
||
115 | 118 | */ |
116 | 119 | public function saveOrder( $updates_ord = array() ) |
117 | 120 | { |
118 | - if ( empty( $this->orderField ) ) |
|
119 | - throw new QueryException( 'Order field is not defined' ); |
|
121 | + if ( empty( $this->orderField ) ) { |
|
122 | + throw new QueryException( 'Order field is not defined' ); |
|
123 | + } |
|
120 | 124 | |
121 | 125 | $query = /** @lang text */ |
122 | 126 | "UPDATE `{$this->table}` SET `{$this->orderField}` = CASE `{$this->primary[0]}` \r\n"; |
@@ -137,16 +141,19 @@ discard block |
||
137 | 141 | */ |
138 | 142 | protected function getPrimaryKeyConditions( $id ) |
139 | 143 | { |
140 | - if ( !is_array( $id ) ) |
|
141 | - $id = [ $id ]; |
|
144 | + if ( !is_array( $id ) ) { |
|
145 | + $id = [ $id ]; |
|
146 | + } |
|
142 | 147 | |
143 | - if ( count( $this->primary ) !== count( $id ) ) |
|
144 | - throw new QueryException( 'Invalid primary key', QueryException::QUERY_CRUD_INVALID_PRIMARY ); |
|
148 | + if ( count( $this->primary ) !== count( $id ) ) { |
|
149 | + throw new QueryException( 'Invalid primary key', QueryException::QUERY_CRUD_INVALID_PRIMARY ); |
|
150 | + } |
|
145 | 151 | |
146 | 152 | $conditions = []; |
147 | 153 | |
148 | - foreach ( $this->primary as $index => $key ) |
|
149 | - $conditions[ $key ] = $id[ $index ]; |
|
154 | + foreach ( $this->primary as $index => $key ) { |
|
155 | + $conditions[ $key ] = $id[ $index ]; |
|
156 | + } |
|
150 | 157 | |
151 | 158 | return $conditions; |
152 | 159 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | * @return $this |
306 | 306 | * @throws \Qpdb\QueryBuilder\Dependencies\QueryException |
307 | 307 | */ |
308 | - public function havingExpression( $whereString, array $bindParams = [], $glue = 'AND' ) |
|
308 | + public function havingExpression( $whereString, array $bindParams = [ ], $glue = 'AND' ) |
|
309 | 309 | { |
310 | 310 | $whereString = $this->queryStructure->bindParamsExpression( $whereString, $bindParams ); |
311 | 311 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | * @return $this |
319 | 319 | * @throws \Qpdb\QueryBuilder\Dependencies\QueryException |
320 | 320 | */ |
321 | - public function orHavingExpression( $whereString, array $bindParams = [] ) |
|
321 | + public function orHavingExpression( $whereString, array $bindParams = [ ] ) |
|
322 | 322 | { |
323 | 323 | $whereString = $this->queryStructure->bindParamsExpression( $whereString, $bindParams ); |
324 | 324 |
@@ -52,7 +52,7 @@ |
||
52 | 52 | if ( '' === $table ) |
53 | 53 | throw new QueryException( 'Table name is empty string!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
54 | 54 | |
55 | - return QueryHelper::addBacktick($table); |
|
55 | + return QueryHelper::addBacktick( $table ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -49,8 +49,9 @@ discard block |
||
49 | 49 | { |
50 | 50 | $table = trim( $table ); |
51 | 51 | |
52 | - if ( '' === $table ) |
|
53 | - throw new QueryException( 'Table name is empty string!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
52 | + if ( '' === $table ) { |
|
53 | + throw new QueryException( 'Table name is empty string!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
54 | + } |
|
54 | 55 | |
55 | 56 | return QueryHelper::addBacktick($table); |
56 | 57 | } |
@@ -62,11 +63,13 @@ discard block |
||
62 | 63 | */ |
63 | 64 | private function validateTableSubQuery( $table ) |
64 | 65 | { |
65 | - if ( $this->statement !== QueryStatement::QUERY_STATEMENT_SELECT ) |
|
66 | - throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
66 | + if ( $this->statement !== QueryStatement::QUERY_STATEMENT_SELECT ) { |
|
67 | + throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
68 | + } |
|
67 | 69 | |
68 | - if ( !is_a( $table, QuerySelect::class ) ) |
|
69 | - throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
70 | + if ( !is_a( $table, QuerySelect::class ) ) { |
|
71 | + throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
72 | + } |
|
70 | 73 | |
71 | 74 | return $table; |
72 | 75 | } |