* @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.
*/
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.
*
* @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 ) {
$this->getName(),
$this->getPrefixedValues( $conditions ),
$functionName
- ) !== false; // DatabaseBase::delete does not always return true for success as documented...
+ );
}
/**
$this->getPrefixedValues( $values ),
$this->getPrefixedValues( $conditions ),
__METHOD__
- ) !== false; // DatabaseBase::update does not always return true for success as documented...
+ );
}
/**
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();
* 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
*
* @since 1.20
*
- * @return IORMTable
+ * @return ORMTable
*/
public static function singleton() {
$class = function_exists( 'get_called_class' ) ? get_called_class() : self::get_called_class();
*
* @param stdClass $result
*
- * @return IORMRow
+ * @return ORMRow
*/
public function newFromDBResult( stdClass $result ) {
return $this->newFromArray( $this->getFieldsFromDBResult( $result ) );
* @param array $data
* @param boolean $loadDefaults
*
- * @return IORMRow
+ * @return ORMRow
*/
public function newFromArray( array $data, $loadDefaults = false ) {
$class = $this->getRowClass();