Revert to arbitrarily old point before initial remote branch creation to help clean up
[lhc/web/wiklou.git] / includes / db / ORMTable.php
index b6e2d52..2f02c6b 100644 (file)
  * @since 1.20
  *
  * @file ORMTable.php
- * @ingroup ORM
  *
  * @licence GNU GPL v2 or later
  * @author Jeroen De Dauw < jeroendedauw@gmail.com >
  */
 
-abstract class ORMTable implements IORMTable {
+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();
 
        /**
         * Gets the db field prefix.
@@ -37,6 +55,26 @@ abstract class ORMTable implements IORMTable {
         */
        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.
         *
@@ -214,7 +252,7 @@ abstract class ORMTable implements IORMTable {
         * @param array $options
         * @param string|null $functionName
         *
-        * @return IORMRow|bool False on failure
+        * @return DBObject|bool False on failure
         */
        public function selectRow( $fields = null, array $conditions = array(),
                                                           array $options = array(), $functionName = null ) {
@@ -330,7 +368,7 @@ abstract class ORMTable implements IORMTable {
                        $this->getName(),
                        $this->getPrefixedValues( $conditions ),
                        $functionName
-               ) !== false; // DatabaseBase::delete does not always return true for success as documented...
+               );
        }
        
        /**
@@ -437,7 +475,7 @@ abstract class ORMTable implements IORMTable {
                        $this->getPrefixedValues( $values ),
                        $this->getPrefixedValues( $conditions ),
                        __METHOD__
-               ) !== false; // DatabaseBase::update does not always return true for success as documented...
+               );
        }
 
        /**
@@ -451,7 +489,7 @@ abstract class ORMTable implements IORMTable {
        public function updateSummaryFields( $summaryFields = null, array $conditions = array() ) {
                $this->setReadDb( DB_MASTER );
 
-               foreach ( $this->select( null, $conditions ) as /* IORMRow */ $item ) {
+               foreach ( $this->select( null, $conditions ) as /* ORMRow */ $item ) {
                        $item->loadSummaryFields( $summaryFields );
                        $item->setSummaryMode( true );
                        $item->save();
@@ -465,6 +503,11 @@ abstract class ORMTable implements IORMTable {
         * 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
@@ -556,7 +599,7 @@ abstract class ORMTable implements IORMTable {
         *
         * @since 1.20
         *
-        * @return IORMTable
+        * @return ORMTable
         */
        public static function singleton() {
                $class = function_exists( 'get_called_class' ) ? get_called_class() : self::get_called_class();
@@ -624,7 +667,7 @@ abstract class ORMTable implements IORMTable {
         *
         * @param stdClass $result
         *
-        * @return IORMRow
+        * @return ORMRow
         */
        public function newFromDBResult( stdClass $result ) {
                return $this->newFromArray( $this->getFieldsFromDBResult( $result ) );
@@ -638,7 +681,7 @@ abstract class ORMTable implements IORMTable {
         * @param array $data
         * @param boolean $loadDefaults
         *
-        * @return IORMRow
+        * @return ORMRow
         */
        public function newFromArray( array $data, $loadDefaults = false ) {
                $class = $this->getRowClass();