@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | public function __construct() |
39 | 39 | { |
40 | 40 | $this->table = $this->getTableName(); |
41 | - $this->primary = (array)$this->getPrimaryKey(); |
|
41 | + $this->primary = ( array ) $this->getPrimaryKey(); |
|
42 | 42 | $this->orderField = $this->getOrderField(); |
43 | 43 | } |
44 | 44 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @return array|bool |
66 | 66 | * @throws QueryException |
67 | 67 | */ |
68 | - public function getRowById( $id, array $fields = [] ) |
|
68 | + public function getRowById( $id, array $fields = [ ] ) |
|
69 | 69 | { |
70 | 70 | $conditions = $this->getPrimaryKeyConditions( $id ); |
71 | 71 | $result = QueryBuild::select( $this->table )->fields( $fields ); |
@@ -130,14 +130,14 @@ discard block |
||
130 | 130 | throw new QueryException( 'Order field is not defined' ); |
131 | 131 | |
132 | 132 | $query = /** @lang text */ |
133 | - "UPDATE `{$this->table}` SET `{$this->orderField}` = CASE `{$this->primary[0]}` \r\n"; |
|
133 | + "UPDATE `{$this->table}` SET `{$this->orderField}` = CASE `{$this->primary[ 0 ]}` \r\n"; |
|
134 | 134 | foreach ( $updates_ord as $position => $id ) { |
135 | 135 | $pos = $position + 1; |
136 | 136 | $query .= " WHEN '$id' THEN '$pos' \r\n"; |
137 | 137 | } |
138 | 138 | $query .= "ELSE `{$this->orderField}` END"; |
139 | 139 | |
140 | - return PdoWrapperService::getInstance()->query($query, []); |
|
140 | + return PdoWrapperService::getInstance()->query( $query, [ ] ); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
@@ -149,12 +149,12 @@ discard block |
||
149 | 149 | protected function getPrimaryKeyConditions( $id ) |
150 | 150 | { |
151 | 151 | |
152 | - $id = (array)$id; |
|
152 | + $id = ( array ) $id; |
|
153 | 153 | |
154 | 154 | if ( count( $this->primary ) !== count( $id ) ) |
155 | 155 | throw new QueryException( 'Invalid primary key', QueryException::QUERY_CRUD_INVALID_PRIMARY ); |
156 | 156 | |
157 | - $conditions = []; |
|
157 | + $conditions = [ ]; |
|
158 | 158 | |
159 | 159 | foreach ( $this->primary as $index => $key ) |
160 | 160 | $conditions[ $key ] = $id[ $index ]; |
@@ -69,8 +69,9 @@ discard block |
||
69 | 69 | { |
70 | 70 | $conditions = $this->getPrimaryKeyConditions( $id ); |
71 | 71 | $result = QueryBuild::select( $this->table )->fields( $fields ); |
72 | - foreach ( $conditions as $field => $value ) |
|
73 | - $result->whereEqual( $field, $value ); |
|
72 | + foreach ( $conditions as $field => $value ) { |
|
73 | + $result->whereEqual( $field, $value ); |
|
74 | + } |
|
74 | 75 | |
75 | 76 | return $result->first()->execute(); |
76 | 77 | } |
@@ -85,8 +86,9 @@ discard block |
||
85 | 86 | { |
86 | 87 | $conditions = $this->getPrimaryKeyConditions( $id ); |
87 | 88 | $result = QueryBuild::delete( $this->table ); |
88 | - foreach ( $conditions as $field => $value ) |
|
89 | - $result->whereEqual( $field, $value ); |
|
89 | + foreach ( $conditions as $field => $value ) { |
|
90 | + $result->whereEqual( $field, $value ); |
|
91 | + } |
|
90 | 92 | |
91 | 93 | return $result->execute(); |
92 | 94 | } |
@@ -101,8 +103,9 @@ discard block |
||
101 | 103 | { |
102 | 104 | $conditions = $this->getPrimaryKeyConditions( $id ); |
103 | 105 | $result = QueryBuild::update( $this->table ); |
104 | - foreach ( $conditions as $field => $value ) |
|
105 | - $result->whereEqual( $field, $value ); |
|
106 | + foreach ( $conditions as $field => $value ) { |
|
107 | + $result->whereEqual( $field, $value ); |
|
108 | + } |
|
106 | 109 | $result->setFieldsByArray( $arrayUpdater ); |
107 | 110 | |
108 | 111 | return $result->execute(); |
@@ -126,8 +129,9 @@ discard block |
||
126 | 129 | */ |
127 | 130 | public function saveOrder( $updates_ord = array() ) |
128 | 131 | { |
129 | - if ( empty( $this->orderField ) ) |
|
130 | - throw new QueryException( 'Order field is not defined' ); |
|
132 | + if ( empty( $this->orderField ) ) { |
|
133 | + throw new QueryException( 'Order field is not defined' ); |
|
134 | + } |
|
131 | 135 | |
132 | 136 | $query = /** @lang text */ |
133 | 137 | "UPDATE `{$this->table}` SET `{$this->orderField}` = CASE `{$this->primary[0]}` \r\n"; |
@@ -151,13 +155,15 @@ discard block |
||
151 | 155 | |
152 | 156 | $id = (array)$id; |
153 | 157 | |
154 | - if ( count( $this->primary ) !== count( $id ) ) |
|
155 | - throw new QueryException( 'Invalid primary key', QueryException::QUERY_CRUD_INVALID_PRIMARY ); |
|
158 | + if ( count( $this->primary ) !== count( $id ) ) { |
|
159 | + throw new QueryException( 'Invalid primary key', QueryException::QUERY_CRUD_INVALID_PRIMARY ); |
|
160 | + } |
|
156 | 161 | |
157 | 162 | $conditions = []; |
158 | 163 | |
159 | - foreach ( $this->primary as $index => $key ) |
|
160 | - $conditions[ $key ] = $id[ $index ]; |
|
164 | + foreach ( $this->primary as $index => $key ) { |
|
165 | + $conditions[ $key ] = $id[ $index ]; |
|
166 | + } |
|
161 | 167 | |
162 | 168 | return $conditions; |
163 | 169 | } |