Abstract Class Horde_Rdo_Mapper

Description

Implements interfaces:

  • Countable (internal interface)

Rdo Mapper class. Controls mapping of entity obects (instances of Horde_Rdo_Base) from and to Horde_Rdo_Adapters.

Public properties: $adapter - Horde_Rdo_Adapter that stores this Mapper's objects.

$inflector - Horde_Rdo_Inflector object for doing table name to class name, class name to table name, etc. conversions.

$model - The Horde_Rdo_Model object describing the main table of this entity.

  • abstract:

Located in /Rdo/lib/Horde/Rdo/Mapper.php (line 25)


	
			
Direct descendents
Class Description
 class Clotho_Mapper Base Mapper class for Clotho - defines getAdapter() so subclasses stay simple.
 class TaskMapper
 class UserMapper
 class ProxyMapper This class will stand in for our table's Mapper.
Variable Summary
Method Summary
 integer count ([mixed $query = null])
 Horde_Rdo_Base create (array $fields)
 integer delete (string|Horde_Rdo_Base|Horde_Rdo_Query $object)
 boolean exists (mixed $query)
 void find ()
 Horde_Rdo_Base map ([array $fields = array()])
 void setAdapter (Horde_Rdo_Adapter $adapter)
 void sortBy (string $field, [constant $direction = Horde_Rdo::SORT_ASC])
 integer update (string|Rdo $object, [array $fields = null])
 mixed __get (string $key)
Variables
string $_classname (line 44)

What class should this Mapper create for objects? Defaults to the Mapper subclass' name minus "Mapper". So if the Rdo_Mapper subclass is UserMapper, it will default to trying to create User objects.

  • access: protected
array $_defaultSortRules (line 87)

Default sorting rules to use for all queries made with this

mapper. Each element of this array can either be a tuple (a single numerically indexed array) of a field name followed by a sort order (Horde_Rdo::SORT_ASC or Horde_Rdo::SORT_DESC), or just a field name. If just a field name is specified the default sorting order (ascending) will be used.

  • access: protected
array $_lazyFields = array() (line 60)

Fields that should only be read from the database when they are accessed.

  • access: protected
array $_lazyRelationships = array() (line 75)

Relationships that should only be read from the database when they are accessed.

  • access: protected
array $_relationships = array() (line 67)

Relationships for this entity.

  • access: protected

Redefined in descendants as:
boolean $_setTimestamps = true (line 34)

If this is true and fields named created and updated are present, Rdo will automatically set creation and last updated timestamps. Timestamps are always GMT for portability.

  • access: protected
string $_table (line 52)

The name of the database table (or view, etc.) that holds this Mapper's objects.

  • access: protected

Redefined in descendants as:
Methods
count (line 249)

Count objects that match $query.

  • return: All objects matching $query.
  • access: public
integer count ([mixed $query = null])
  • mixed $query: The query to count matches of.

Implementation of:
Countable::count
create (line 274)

Create a new object in the backend with $fields as initial values.

  • return: The newly created object.
  • access: public
Horde_Rdo_Base create (array $fields)
  • array $fields: Array of field names => initial values.
delete (line 341)

Deletes a record from the backend. $object can be either a primary key, an Rdo_Query object, or an Rdo object.

  • return: Number of objects deleted.
  • access: public
integer delete (string|Horde_Rdo_Base|Horde_Rdo_Query $object)
exists (line 262)

Check if at least one object matches $query.

  • return: True or false.
  • access: public
boolean exists (mixed $query)
  • mixed $query: Either a primary key, an array of keys => values, or an Horde_Rdo_Query object.
find (line 375)

Find can be called in several ways.

Primary key mode: pass find() a single primary key or an array of primary keys, and it will return either a single object or a Horde_Rdo_List of objects matching those primary keys.

Find mode: otherwise the first argument to find should be a find mode. The defaults modes are Rdo::FIND_FIRST (returns the first object matching the rest of the query), and Rdo::FIND_ALL (return a Horde_Rdo_List of all matches).

When using a find mode, the second argument can be blank (find all objects or the first object depending on find mode), an associative array (keys are fields, values are the values those fields must match exactly), or an Rdo_Query object, which defines arbitrarily complex find rules.

  • access: public
void find ()
getAdapter (line 179)

getAdapter() must be overridden by Horde_Rdo_Mapper subclasses if they don't provide $adapter in some other way (by calling setAdapter() or on construction, for example), and there is no global Adapter.

Horde_Rdo_Adapter getAdapter ()

Redefined in descendants as:
map (line 198)

Create an instance of $this->_classname from a set of data.

Horde_Rdo_Base map ([array $fields = array()])
  • array $fields: Field names/default values for the new object.
setAdapter (line 164)

Associate an adapter with this mapper. Not needed in the general case if getAdapter() is overridden in the concrete Mapper implementation.

void setAdapter (Horde_Rdo_Adapter $adapter)
sortBy (line 457)

Set a default sort field and order for all queries done with this Mapper.

  • access: public
void sortBy (string $field, [constant $direction = Horde_Rdo::SORT_ASC])
  • string $field: Field to sort by
  • constant $direction: Sort ascending (Horde_Rdo::SORT_ASC) or descending (Horde_Rdo::SORT_DESC). Defaults to ascending.
update (line 305)

Updates a record in the backend. $object can be either a primary key or an Rdo object. If $object is an Rdo instance then $fields will be ignored as values will be pulled from the object.

  • return: Number of objects updated.
  • access: public
integer update (string|Rdo $object, [array $fields = null])
  • string|Rdo $object: The Rdo instance or unique id to update.
  • array $fields: If passing a unique id, the array of field properties to set for $object.
__get (line 121)

Provide read-only, on-demand access to several properties. This method will only be called for properties that aren't already present; once a property is fetched once it is cached and returned directly on any subsequent access.

These properties are available:

adapter: The Horde_Rdo_Adapter this mapper is using to talk to the database.

inflector: The Horde_Rdo_Inflector this mapper uses to translate between PHP class, database table, and database field/key names.

model: The Horde_Rdo_Model object describing the table or view this Mapper manages.

fields: Array of all field names that are loaded up front (eager loading) from the Model.

lazyFields: Array of fields that are only loaded when accessed.

relationships: Array of relationships to other Models.

lazyRelationships: Array of relationships to other Models which are only loaded when accessed.

  • return: Value of $key
  • access: public
mixed __get (string $key)
  • string $key: Property name to fetch

Documentation generated on Sun, 30 Jan 2011 05:19:30 +0000 by phpDocumentor 1.4.3