X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fdb%2FORMTable.php;h=b6e2d526565a9b6598389a7f7c7ec46460684cff;hb=b64452a3f72c93f706582f8ce1d4669ade0d2e73;hp=2f02c6b290ffdd38a74e72de9fbe26f6e5bc2811;hpb=c9480d2eeed7c50c5ca554106706cbd289de0993;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/db/ORMTable.php b/includes/db/ORMTable.php index 2f02c6b290..b6e2d52656 100644 --- a/includes/db/ORMTable.php +++ b/includes/db/ORMTable.php @@ -20,31 +20,13 @@ * @since 1.20 * * @file ORMTable.php + * @ingroup ORM * * @licence GNU GPL v2 or later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ -abstract class ORMTable { - - /** - * Returns the name of the database table objects of this type are stored in. - * - * @since 1.20 - * - * @return string - */ - public abstract function getName(); - - /** - * Returns the name of a ORMRow deriving class that - * represents single rows in this table. - * - * @since 1.20 - * - * @return string - */ - public abstract function getRowClass(); +abstract class ORMTable implements IORMTable { /** * Gets the db field prefix. @@ -55,26 +37,6 @@ abstract class ORMTable { */ protected abstract function getFieldPrefix(); - /** - * Returns an array with the fields and their types this object contains. - * This corresponds directly to the fields in the database, without prefix. - * - * field name => type - * - * Allowed types: - * * id - * * str - * * int - * * float - * * bool - * * array - * - * @since 1.20 - * - * @return array - */ - public abstract function getFields(); - /** * Cache for instances, used by the singleton method. * @@ -252,7 +214,7 @@ abstract class ORMTable { * @param array $options * @param string|null $functionName * - * @return DBObject|bool False on failure + * @return IORMRow|bool False on failure */ public function selectRow( $fields = null, array $conditions = array(), array $options = array(), $functionName = null ) { @@ -368,7 +330,7 @@ abstract class ORMTable { $this->getName(), $this->getPrefixedValues( $conditions ), $functionName - ); + ) !== false; // DatabaseBase::delete does not always return true for success as documented... } /** @@ -475,7 +437,7 @@ abstract class ORMTable { $this->getPrefixedValues( $values ), $this->getPrefixedValues( $conditions ), __METHOD__ - ); + ) !== false; // DatabaseBase::update does not always return true for success as documented... } /** @@ -489,7 +451,7 @@ abstract class ORMTable { public function updateSummaryFields( $summaryFields = null, array $conditions = array() ) { $this->setReadDb( DB_MASTER ); - foreach ( $this->select( null, $conditions ) as /* ORMRow */ $item ) { + foreach ( $this->select( null, $conditions ) as /* IORMRow */ $item ) { $item->loadSummaryFields( $summaryFields ); $item->setSummaryMode( true ); $item->save(); @@ -503,11 +465,6 @@ abstract class ORMTable { * their values as value. The field names are prefixed with the * db field prefix. * - * Field names can also be provided as an array with as first element a table name, such as - * $conditions = array( - * array( array( 'tablename', 'fieldname' ), $value ), - * ); - * * @since 1.20 * * @param array $values @@ -599,7 +556,7 @@ abstract class ORMTable { * * @since 1.20 * - * @return ORMTable + * @return IORMTable */ public static function singleton() { $class = function_exists( 'get_called_class' ) ? get_called_class() : self::get_called_class(); @@ -667,7 +624,7 @@ abstract class ORMTable { * * @param stdClass $result * - * @return ORMRow + * @return IORMRow */ public function newFromDBResult( stdClass $result ) { return $this->newFromArray( $this->getFieldsFromDBResult( $result ) ); @@ -681,7 +638,7 @@ abstract class ORMTable { * @param array $data * @param boolean $loadDefaults * - * @return ORMRow + * @return IORMRow */ public function newFromArray( array $data, $loadDefaults = false ) { $class = $this->getRowClass();