Index: trunk/phase3/includes/DBDataObject.php |
— | — | @@ -129,7 +129,7 @@ |
130 | 130 | } |
131 | 131 | |
132 | 132 | if ( is_null( $fields ) ) { |
133 | | - $fields = array_keys( $this->getFieldTypes() ); |
| 133 | + $fields = array_keys( $this->table->getFieldTypes() ); |
134 | 134 | } |
135 | 135 | |
136 | 136 | if ( $skipLoaded ) { |
— | — | @@ -137,14 +137,14 @@ |
138 | 138 | } |
139 | 139 | |
140 | 140 | if ( count( $fields ) > 0 ) { |
141 | | - $result = $this->rawSelectRow( |
142 | | - $this->getPrefixedFields( $fields ), |
143 | | - array( $this->getPrefixedField( 'id' ) => $this->getId() ), |
| 141 | + $result = $this->table->rawSelectRow( |
| 142 | + $this->table->getPrefixedFields( $fields ), |
| 143 | + array( $this->table->getPrefixedField( 'id' ) => $this->getId() ), |
144 | 144 | array( 'LIMIT' => 1 ) |
145 | 145 | ); |
146 | 146 | |
147 | 147 | if ( $result !== false ) { |
148 | | - $this->setFields( $this->getFieldsFromDBResult( $result ), $override ); |
| 148 | + $this->setFields( $this->table->getFieldsFromDBResult( $result ), $override ); |
149 | 149 | return true; |
150 | 150 | } |
151 | 151 | |
— | — | @@ -276,7 +276,7 @@ |
277 | 277 | protected function getWriteValues() { |
278 | 278 | $values = array(); |
279 | 279 | |
280 | | - foreach ( $this->getFieldTypes() as $name => $type ) { |
| 280 | + foreach ( $this->table->getFieldTypes() as $name => $type ) { |
281 | 281 | if ( array_key_exists( $name, $this->fields ) ) { |
282 | 282 | $value = $this->fields[$name]; |
283 | 283 | |
— | — | @@ -287,7 +287,7 @@ |
288 | 288 | $value = serialize( $value ); |
289 | 289 | } |
290 | 290 | |
291 | | - $values[$this->getFieldPrefix() . $name] = $value; |
| 291 | + $values[$this->table->getPrefixedField( $name )] = $value; |
292 | 292 | } |
293 | 293 | } |
294 | 294 | |
— | — | @@ -336,7 +336,7 @@ |
337 | 337 | * @param boolean $override |
338 | 338 | */ |
339 | 339 | public function loadDefaults( $override = true ) { |
340 | | - $this->setFields( $this->getDefaults(), $override ); |
| 340 | + $this->setFields( $this->table->getDefaults(), $override ); |
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
— | — | @@ -366,9 +366,9 @@ |
367 | 367 | $dbw = wfGetDB( DB_MASTER ); |
368 | 368 | |
369 | 369 | $success = $dbw->update( |
370 | | - $this->getDBTable(), |
| 370 | + $this->table->getDBTable(), |
371 | 371 | $this->getWriteValues(), |
372 | | - array( $this->getFieldPrefix() . 'id' => $this->getId() ), |
| 372 | + array( $this->table->getPrefixedField( 'id' ) => $this->getId() ), |
373 | 373 | __METHOD__ |
374 | 374 | ); |
375 | 375 | |
— | — | @@ -386,7 +386,7 @@ |
387 | 387 | $dbw = wfGetDB( DB_MASTER ); |
388 | 388 | |
389 | 389 | $result = $dbw->insert( |
390 | | - $this->getDBTable(), |
| 390 | + $this->table->getDBTable(), |
391 | 391 | $this->getWriteValues(), |
392 | 392 | __METHOD__, |
393 | 393 | array( 'IGNORE' ) |
— | — | @@ -409,7 +409,7 @@ |
410 | 410 | public function remove() { |
411 | 411 | $this->beforeRemove(); |
412 | 412 | |
413 | | - $success = static::delete( array( 'id' => $this->getId() ) ); |
| 413 | + $success = $this->table->delete( array( 'id' => $this->getId() ) ); |
414 | 414 | |
415 | 415 | if ( $success ) { |
416 | 416 | $this->onRemoved(); |
— | — | @@ -588,12 +588,12 @@ |
589 | 589 | |
590 | 590 | $dbw = wfGetDB( DB_MASTER ); |
591 | 591 | |
592 | | - $fullField = $this->getPrefixedField( $field ); |
| 592 | + $fullField = $this->table->getPrefixedField( $field ); |
593 | 593 | |
594 | 594 | $success = $dbw->update( |
595 | | - $this->getDBTable(), |
| 595 | + $this->table->getDBTable(), |
596 | 596 | array( "$fullField=$fullField" . ( $isNegative ? '-' : '+' ) . $absoluteAmount ), |
597 | | - array( $this->getPrefixedField( 'id' ) => $this->getId() ), |
| 597 | + array( $this->table->getPrefixedField( 'id' ) => $this->getId() ), |
598 | 598 | __METHOD__ |
599 | 599 | ); |
600 | 600 | |
— | — | @@ -605,30 +605,6 @@ |
606 | 606 | } |
607 | 607 | |
608 | 608 | /** |
609 | | - * Selects the the specified fields of the records matching the provided |
610 | | - * conditions. Field names do NOT get prefixed. |
611 | | - * |
612 | | - * @since 1.20 |
613 | | - * |
614 | | - * @param array $fields |
615 | | - * @param array $conditions |
616 | | - * @param array $options |
617 | | - * |
618 | | - * @return ResultWrapper |
619 | | - */ |
620 | | - protected static function rawSelectRow( array $fields, array $conditions = array(), array $options = array() ) { |
621 | | - $dbr = wfGetDB( static::getReadDb() ); |
622 | | - |
623 | | - return $dbr->selectRow( |
624 | | - static::getDBTable(), |
625 | | - $fields, |
626 | | - $conditions, |
627 | | - __METHOD__, |
628 | | - $options |
629 | | - ); |
630 | | - } |
631 | | - |
632 | | - /** |
633 | 609 | * Return the names of the fields. |
634 | 610 | * |
635 | 611 | * @since 1.20 |
— | — | @@ -684,7 +660,7 @@ |
685 | 661 | */ |
686 | 662 | protected function fieldsChanged( DBDataObject $object, $excludeSummaryFields = false ) { |
687 | 663 | foreach ( $this->fields as $name => $value ) { |
688 | | - $excluded = $excludeSummaryFields && in_array( $name, $this->getSummaryFields() ); |
| 664 | + $excluded = $excludeSummaryFields && in_array( $name, $this->table->getSummaryFields() ); |
689 | 665 | |
690 | 666 | if ( !$excluded && $object->getField( $name ) !== $value ) { |
691 | 667 | return true; |
Index: trunk/phase3/includes/DBTable.php |
— | — | @@ -201,6 +201,30 @@ |
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
| 205 | + * Selects the the specified fields of the records matching the provided |
| 206 | + * conditions. Field names do NOT get prefixed. |
| 207 | + * |
| 208 | + * @since 1.20 |
| 209 | + * |
| 210 | + * @param array $fields |
| 211 | + * @param array $conditions |
| 212 | + * @param array $options |
| 213 | + * |
| 214 | + * @return ResultWrapper |
| 215 | + */ |
| 216 | + public function rawSelectRow( array $fields, array $conditions = array(), array $options = array() ) { |
| 217 | + $dbr = wfGetDB( $this->getReadDb() ); |
| 218 | + |
| 219 | + return $dbr->selectRow( |
| 220 | + $this->getDBTable(), |
| 221 | + $fields, |
| 222 | + $conditions, |
| 223 | + __METHOD__, |
| 224 | + $options |
| 225 | + ); |
| 226 | + } |
| 227 | + |
| 228 | + /** |
205 | 229 | * Selects the the specified fields of the first record matching the provided |
206 | 230 | * conditions and returns it as an associative array, or false when nothing matches. |
207 | 231 | * This method makes use of selectFields and expects the same parameters and |