Adding interfaces for ORM row and table classes so these can be used for type hinting...
[lhc/web/wiklou.git] / includes / db / ORMTable.php
index 2f02c6b..cc84d65 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 {
-
-       /**
-        * 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 ) {
@@ -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();