$_setTimestamps
$_setTimestamps : boolean
If this is true and fields named created_at and updated_at are present, Rdo will automatically set creation and last updated timestamps.
Timestamps are always GMT for portability.
Rdo Mapper class.
Controls mapping of entity obects (instances of Horde_Rdo_Base) from and to Horde_Db_Adapters.
Public properties: $adapter - Horde_Db_Adapter that stores this Mapper's objects.
$inflector - The Horde_Support_Inflector this mapper uses to singularize and pluralize PHP class, database table, and database field/key names.
$table - The Horde_Db_Adapter_Base_TableDefinition object describing the main table of this entity.
$_factory : \Horde_Rdo_Factory
The caching factory, if used
setFactory(\Horde_Rdo_Factory $factory = null) : \Horde_Rdo_Mapper
Attach a Horde_Rdo_Factory to the mapper.
If called without arguments, detaches the mapper from factory
\Horde_Rdo_Factory | $factory | A Factory instance or null |
this mapper
__get(string $key) : mixed
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_Db_Adapter this mapper is using to talk to the database.
factory: The Horde_Rdo_Factory instance, if present
inflector: The Horde_Support_Inflector this Mapper uses to singularize and pluralize PHP class, database table, and database field/key names.
table: The database table or view that this Mapper manages.
tableDefinition: The Horde_Db_Adapter_Base_TableDefinition object describing the table or view this Mapper manages.
fields: Array of all field names that are loaded up front (eager loading) from the table.
lazyFields: Array of fields that are only loaded when accessed.
relationships: Array of relationships to other Mappers.
lazyRelationships: Array of relationships to other Mappers which are only loaded when accessed.
string | $key | Property name to fetch |
Value of $key
map(array $fields = array()) : \Horde_Rdo_Base
Create an instance of $this->_classname from a set of data.
array | $fields | Field names/default values for the new object. |
An instance of $this->_classname with $fields as initial data.
mapFields(\Horde_Rdo_Base $object, array $fields = array())
Update an instance of $this->_classname from a set of data.
\Horde_Rdo_Base | $object | The object to update |
array | $fields | Field names/default values for the object |
tableToMapper(string $table) : \Horde_Rdo_Mapper
Transform a table name to a mapper class name.
string | $table | The database table name to look up. |
A new Mapper instance if it exists, else null.
create(array $fields) : \Horde_Rdo_Base
Create a new object in the backend with $fields as initial values.
array | $fields | Array of field names => initial values. |
The newly created object.
update(string|\Rdo $object, array $fields = null) : integer
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.
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. |
Number of objects updated.
delete(string|\Horde_Rdo_Base|\Horde_Rdo_Query $object) : integer
Deletes a record from the backend. $object can be either a primary key, an Rdo_Query object, or an Rdo object.
string|\Horde_Rdo_Base|\Horde_Rdo_Query | $object | The Rdo object, Horde_Rdo_Query, or unique id to delete. |
Number of objects deleted.
find( $arg = null)
find() can be called in several ways.
Primary key mode: pass find() a numerically indexed array of primary keys, and it will return a list of the objects that correspond to those keys.
If you pass find() no arguments, all objects of this type will be returned.
If you pass find() an associative array, it will be turned into a Horde_Rdo_Query object.
If you pass find() a Horde_Rdo_Query, it will return a list of all objects matching that query.
$arg |
addRelation(string $relationship, \Horde_Rdo_Base $ours, \Horde_Rdo_Base $theirs)
Adds a relation.
string | $relationship | The relationship key in the mapper. |
\Horde_Rdo_Base | $ours | The object from this mapper to add the relation. |
\Horde_Rdo_Base | $theirs | The other object from any mapper to add the relation. |
removeRelation(string $relationship, \Horde_Rdo_Base $ours, \Horde_Rdo_Base $theirs = null) : integer
Removes a relation to one of the relationships defined in the mapper.
This is a proxy to the mapper's removeRelation method.
string | $relationship | The relationship key in the mapper. |
\Horde_Rdo_Base | $ours | The object from this mapper. |
\Horde_Rdo_Base | $theirs | The object to remove from the relation. |
the number of affected relations
findOne( $arg = null)
findOne can be called in several ways.
Primary key mode: pass find() a single primary key, and it will return a single object matching that primary key.
If you pass findOne() no arguments, the first object of this type will be returned.
If you pass findOne() an associative array, it will be turned into a Horde_Rdo_Query object.
If you pass findOne() a Horde_Rdo_Query, it will return the first object matching that query.
$arg |