@@ -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 |
@@ -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 |
@@ -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 | /** |
@@ -26,12 +26,12 @@ discard block |
||
26 | 26 | * @return $this |
27 | 27 | * @throws QueryException |
28 | 28 | */ |
29 | - public function orderBy( $column, array $allowedColumns = [] ) |
|
29 | + public function orderBy( $column, array $allowedColumns = [ ] ) |
|
30 | 30 | { |
31 | 31 | if ( !$this->validateColumn( $column, $allowedColumns ) ) |
32 | 32 | throw new QueryException( 'Invalid column name in ORDER BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME ); |
33 | 33 | |
34 | - $column = $this->queryStructure->prepare($column); |
|
34 | + $column = $this->queryStructure->prepare( $column ); |
|
35 | 35 | $this->queryStructure->setElement( QueryStructure::ORDER_BY, $column ); |
36 | 36 | |
37 | 37 | return $this; |
@@ -44,12 +44,12 @@ discard block |
||
44 | 44 | * @return $this |
45 | 45 | * @throws QueryException |
46 | 46 | */ |
47 | - public function orderByDesc( $column, array $allowedColumns = [] ) |
|
47 | + public function orderByDesc( $column, array $allowedColumns = [ ] ) |
|
48 | 48 | { |
49 | 49 | if ( !$this->validateColumn( $column, $allowedColumns ) ) |
50 | 50 | throw new QueryException( 'Invalid column name in ORDER BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME ); |
51 | 51 | |
52 | - $column = $this->queryStructure->prepare($column); |
|
52 | + $column = $this->queryStructure->prepare( $column ); |
|
53 | 53 | $this->queryStructure->setElement( QueryStructure::ORDER_BY, $column . ' DESC' ); |
54 | 54 | |
55 | 55 | return $this; |
@@ -26,12 +26,12 @@ discard block |
||
26 | 26 | * @return $this |
27 | 27 | * @throws QueryException |
28 | 28 | */ |
29 | - public function groupBy( $column, array $allowedColumns = [] ) |
|
29 | + public function groupBy( $column, array $allowedColumns = [ ] ) |
|
30 | 30 | { |
31 | 31 | if ( !$this->validateColumn( $column, $allowedColumns ) ) |
32 | 32 | throw new QueryException( 'Invalid column name in GROUP BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME ); |
33 | 33 | |
34 | - $column = $this->queryStructure->prepare($column); |
|
34 | + $column = $this->queryStructure->prepare( $column ); |
|
35 | 35 | $this->queryStructure->setElement( QueryStructure::ORDER_BY, $column ); |
36 | 36 | |
37 | 37 | $this->queryStructure->setElement( QueryStructure::GROUP_BY, $column ); |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | * @return $this |
47 | 47 | * @throws QueryException |
48 | 48 | */ |
49 | - public function groupByDesc( $column, array $allowedColumns = [] ) |
|
49 | + public function groupByDesc( $column, array $allowedColumns = [ ] ) |
|
50 | 50 | { |
51 | 51 | if ( !$this->validateColumn( $column, $allowedColumns ) ) |
52 | 52 | throw new QueryException( 'Invalid column name in GROUP BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME ); |
53 | 53 | |
54 | - $column = $this->queryStructure->prepare($column); |
|
54 | + $column = $this->queryStructure->prepare( $column ); |
|
55 | 55 | $this->queryStructure->setElement( QueryStructure::ORDER_BY, $column ); |
56 | 56 | |
57 | 57 | $this->queryStructure->setElement( QueryStructure::GROUP_BY, $column . ' DESC' ); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function __construct() { |
39 | 39 | $this->table = $this->getTableName(); |
40 | - $this->primary = (array)$this->getPrimaryKey(); |
|
40 | + $this->primary = ( array ) $this->getPrimaryKey(); |
|
41 | 41 | $this->orderField = $this->getOrderField(); |
42 | 42 | } |
43 | 43 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @return array|bool |
65 | 65 | * @throws QueryException |
66 | 66 | */ |
67 | - public function getRowById( $id, array $fields = [] ) { |
|
67 | + public function getRowById( $id, array $fields = [ ] ) { |
|
68 | 68 | $conditions = $this->getPrimaryKeyConditions( $id ); |
69 | 69 | $result = QueryBuild::select( $this->table )->fields( $fields ); |
70 | 70 | foreach ( $conditions as $field => $value ) |
@@ -146,14 +146,14 @@ discard block |
||
146 | 146 | throw new QueryException( 'Order field is not defined' ); |
147 | 147 | |
148 | 148 | $query = /** @lang text */ |
149 | - "UPDATE `{$this->table}` SET `{$this->orderField}` = CASE `{$this->primary[0]}` \r\n"; |
|
149 | + "UPDATE `{$this->table}` SET `{$this->orderField}` = CASE `{$this->primary[ 0 ]}` \r\n"; |
|
150 | 150 | foreach ( $updates_ord as $position => $id ) { |
151 | 151 | $pos = $position + 1; |
152 | 152 | $query .= " WHEN '$id' THEN '$pos' \r\n"; |
153 | 153 | } |
154 | 154 | $query .= "ELSE `{$this->orderField}` END"; |
155 | 155 | |
156 | - return PdoWrapperService::getInstance()->query( $query, [] ); |
|
156 | + return PdoWrapperService::getInstance()->query( $query, [ ] ); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | |
@@ -164,12 +164,12 @@ discard block |
||
164 | 164 | */ |
165 | 165 | protected function getPrimaryKeyConditions( $id ) { |
166 | 166 | |
167 | - $id = (array)$id; |
|
167 | + $id = ( array ) $id; |
|
168 | 168 | |
169 | 169 | if ( count( $this->primary ) !== count( $id ) ) |
170 | 170 | throw new QueryException( 'Invalid primary key', QueryException::QUERY_CRUD_INVALID_PRIMARY ); |
171 | 171 | |
172 | - $conditions = []; |
|
172 | + $conditions = [ ]; |
|
173 | 173 | |
174 | 174 | foreach ( $this->primary as $index => $key ) |
175 | 175 | $conditions[ $key ] = $id[ $index ]; |
@@ -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->getSelectFieldsSyntax(); |
|
143 | + $syntax[ ] = $this->getSelectFieldsSyntax(); |
|
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 |