@@ -67,8 +67,9 @@ discard block |
||
| 67 | 67 | public function getRowById( $id, array $fields = [] ) { |
| 68 | 68 | $conditions = $this->getPrimaryKeyConditions( $id ); |
| 69 | 69 | $result = QueryBuild::select( $this->table )->fields( $fields ); |
| 70 | - foreach ( $conditions as $field => $value ) |
|
| 71 | - $result->whereEqual( $field, $value ); |
|
| 70 | + foreach ( $conditions as $field => $value ) { |
|
| 71 | + $result->whereEqual( $field, $value ); |
|
| 72 | + } |
|
| 72 | 73 | |
| 73 | 74 | return $result->first()->execute(); |
| 74 | 75 | } |
@@ -82,8 +83,9 @@ discard block |
||
| 82 | 83 | public function deleteRowById( $id ) { |
| 83 | 84 | $conditions = $this->getPrimaryKeyConditions( $id ); |
| 84 | 85 | $result = QueryBuild::delete( $this->table ); |
| 85 | - foreach ( $conditions as $field => $value ) |
|
| 86 | - $result->whereEqual( $field, $value ); |
|
| 86 | + foreach ( $conditions as $field => $value ) { |
|
| 87 | + $result->whereEqual( $field, $value ); |
|
| 88 | + } |
|
| 87 | 89 | |
| 88 | 90 | return $result->execute(); |
| 89 | 91 | } |
@@ -97,8 +99,9 @@ discard block |
||
| 97 | 99 | public function updateRowById( $id, array $arrayUpdater ) { |
| 98 | 100 | $conditions = $this->getPrimaryKeyConditions( $id ); |
| 99 | 101 | $result = QueryBuild::update( $this->table ); |
| 100 | - foreach ( $conditions as $field => $value ) |
|
| 101 | - $result->whereEqual( $field, $value ); |
|
| 102 | + foreach ( $conditions as $field => $value ) { |
|
| 103 | + $result->whereEqual( $field, $value ); |
|
| 104 | + } |
|
| 102 | 105 | $result->setFieldsByArray( $arrayUpdater ); |
| 103 | 106 | |
| 104 | 107 | return $result->execute(); |
@@ -120,8 +123,9 @@ discard block |
||
| 120 | 123 | * @throws QueryException |
| 121 | 124 | */ |
| 122 | 125 | public function getMaxOrder( $nullToZero = false ) { |
| 123 | - if ( empty( $this->orderField ) ) |
|
| 124 | - throw new QueryException( 'Order field is not defined' ); |
|
| 126 | + if ( empty( $this->orderField ) ) { |
|
| 127 | + throw new QueryException( 'Order field is not defined' ); |
|
| 128 | + } |
|
| 125 | 129 | |
| 126 | 130 | $result = QueryBuild::select( $this->table ) |
| 127 | 131 | ->fieldExpression( "MAX(`{$this->orderField}`)", "max_order_column_alias" ) |
@@ -142,8 +146,9 @@ discard block |
||
| 142 | 146 | * @throws QueryException |
| 143 | 147 | */ |
| 144 | 148 | public function saveOrder( $updates_ord = array() ) { |
| 145 | - if ( empty( $this->orderField ) ) |
|
| 146 | - throw new QueryException( 'Order field is not defined' ); |
|
| 149 | + if ( empty( $this->orderField ) ) { |
|
| 150 | + throw new QueryException( 'Order field is not defined' ); |
|
| 151 | + } |
|
| 147 | 152 | |
| 148 | 153 | $query = /** @lang text */ |
| 149 | 154 | "UPDATE `{$this->table}` SET `{$this->orderField}` = CASE `{$this->primary[0]}` \r\n"; |
@@ -166,13 +171,15 @@ discard block |
||
| 166 | 171 | |
| 167 | 172 | $id = (array)$id; |
| 168 | 173 | |
| 169 | - if ( count( $this->primary ) !== count( $id ) ) |
|
| 170 | - throw new QueryException( 'Invalid primary key', QueryException::QUERY_CRUD_INVALID_PRIMARY ); |
|
| 174 | + if ( count( $this->primary ) !== count( $id ) ) { |
|
| 175 | + throw new QueryException( 'Invalid primary key', QueryException::QUERY_CRUD_INVALID_PRIMARY ); |
|
| 176 | + } |
|
| 171 | 177 | |
| 172 | 178 | $conditions = []; |
| 173 | 179 | |
| 174 | - foreach ( $this->primary as $index => $key ) |
|
| 175 | - $conditions[ $key ] = $id[ $index ]; |
|
| 180 | + foreach ( $this->primary as $index => $key ) { |
|
| 181 | + $conditions[ $key ] = $id[ $index ]; |
|
| 182 | + } |
|
| 176 | 183 | |
| 177 | 184 | return $conditions; |
| 178 | 185 | } |