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.
Methods summary
public
|
|
public
mixed
|
#
__get( string $key )
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.
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.
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.
Parameters
- $key
- Property name to fetch
Returns
mixed Value of $key
|
public
Horde_Rdo_Base
|
#
map( array $fields = array() )
Create an instance of $this->_classname from a set of data.
Create an instance of $this->_classname from a set of data.
Parameters
- $fields
- Field names/default values for the new object.
Returns
Horde_Rdo_Base
An instance of $this->_classname with $fields
as initial data.
See
$_classname
|
public
|
#
mapFields( Horde_Rdo_Base $object, array $fields = array() )
Update an instance of $this->_classname from a set of data.
Update an instance of $this->_classname from a set of data.
Parameters
- $object
- The object to update
- $fields
- Field names/default values for the object
|
public
Horde_Rdo_Mapper
|
#
tableToMapper( string $table )
Transform a table name to a mapper class name.
Transform a table name to a mapper class name.
Parameters
- $table
- The database table name to look up.
Returns
|
public
string
|
#
mapperToTable( )
Transform this mapper's class name to a database table name.
Transform this mapper's class name to a database table name.
Returns
string The database table name.
|
public
string
|
#
mapperToEntity( )
Transform this mapper's class name to an entity class name.
Transform this mapper's class name to an entity class name.
Returns
string A Horde_Rdo_Base concrete class name if the class exists, else null.
|
public
integer
|
#
count( mixed $query = null )
Count objects that match $query.
Count objects that match $query.
Parameters
- $query
- The query to count matches of.
Returns
integer All objects matching $query.
Implementation of
Countable::count()
|
public
boolean
|
#
exists( mixed $query )
Check if at least one object matches $query.
Check if at least one object matches $query.
Parameters
- $query
- <p>Either a primary key, an array of keys
=> values, or a Horde_Rdo_Query object.</p>
Returns
boolean True or false.
|
public
Horde_Rdo_Base
|
#
create( array $fields )
Create a new object in the backend with $fields as initial values.
Create a new object in the backend with $fields as initial values.
Parameters
- $fields
- Array of field names => initial values.
Returns
|
public
integer
|
#
update( string|Rdo $object, array $fields = null )
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.
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.
Parameters
- $object
- The Rdo instance or unique id to update.
- $fields
- <p>If passing a unique id, the array of field properties
to set for $object.</p>
Returns
integer Number of objects updated.
|
public
integer
|
#
delete( string|Horde_Rdo_Base |Horde_Rdo_Query $object )
Deletes a record from the backend. $object can be either a
primary key, an Rdo_Query object, or an Rdo object.
Deletes a record from the backend. $object can be either a
primary key, an Rdo_Query object, or an Rdo object.
Parameters
- $object
- <p>The Rdo object,
Horde_Rdo_Query, or unique id to delete.</p>
Returns
integer Number of objects deleted.
|
public
|
#
find( mixed $arg = null )
find() can be called in several ways.
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.
|
public
|
#
findOne( mixed $arg = null )
findOne can be called in several ways.
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.
|
public
|
#
sortBy( string $sort )
Set a default sort rule for all queries done with this Mapper.
Set a default sort rule for all queries done with this Mapper.
Parameters
- $sort
- SQL sort fragment, such as 'updated DESC'
|