PHP 클래스 Horde_Rdo_Mapper, horde

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.
상속: implements Countable
파일 보기 프로젝트 열기: horde/horde 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_classname string 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.
$_defaultSort string Default sorting rule to use for all queries made with this mapper. This is a SQL ORDER BY fragment (without 'ORDER BY').
$_factory Horde_Rdo_Factory The caching factory, if used
$_lazyFields array Fields that should only be read from the database when they are accessed.
$_lazyRelationships array Relationships that should only be read from the database when they are accessed.
$_relationships array Relationships for this entity.
$_setTimestamps boolean Timestamps are always GMT for portability.
$_tableDefinition Horde_Db_Adapter_Base_TableDefinition The definition of the database table (or view, etc.) that holds this Mapper's objects.

공개 메소드들

메소드 설명
__construct ( Horde_Db_Adapter $adapter )
__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.
addRelation ( string $relationship, Horde_Rdo_Base $ours, Horde_Rdo_Base $theirs ) Adds a relation.
count ( mixed $query = null ) : integer Count objects that match $query.
create ( array $fields ) : Horde_Rdo_Base Create a new object in the backend with $fields as initial values.
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.
exists ( mixed $query ) : boolean Check if at least one object matches $query.
find ( $arg = null ) find() can be called in several ways.
findOne ( $arg = null ) findOne can be called in several ways.
map ( array $fields = [] ) : Horde_Rdo_Base Create an instance of $this->_classname from a set of data.
mapFields ( Horde_Rdo_Base $object, array $fields = [] ) Update an instance of $this->_classname from a set of data.
mapperToEntity ( ) : string Transform this mapper's class name to an entity class name.
mapperToTable ( ) : string Transform this mapper's class name to a database table name.
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.
setFactory ( Horde_Rdo_Factory $factory = null ) : Horde_Rdo_Mapper Attach a Horde_Rdo_Factory to the mapper.
sortBy ( string $sort ) Set a default sort rule for all queries done with this Mapper.
tableToMapper ( string $table ) : Horde_Rdo_Mapper Transform a table name to a mapper class name.
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.

메소드 상세

__construct() 공개 메소드

public __construct ( Horde_Db_Adapter $adapter )
$adapter Horde_Db_Adapter

__get() 공개 메소드

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.
public __get ( string $key ) : mixed
$key string Property name to fetch
리턴 mixed Value of $key

addRelation() 공개 메소드

- For one-to-one relations, simply updates the relation field. - For one-to-many relations, updates the related object's relation field. - For many-to-many relations, adds an entry in the "through" table. - Performs a no-op if the peer is already related.
public addRelation ( string $relationship, Horde_Rdo_Base $ours, Horde_Rdo_Base $theirs )
$relationship string The relationship key in the mapper.
$ours Horde_Rdo_Base The object from this mapper to add the relation.
$theirs Horde_Rdo_Base The other object from any mapper to add the relation.

count() 공개 메소드

Count objects that match $query.
public count ( mixed $query = null ) : integer
$query mixed The query to count matches of.
리턴 integer All objects matching $query.

create() 공개 메소드

Create a new object in the backend with $fields as initial values.
public create ( array $fields ) : Horde_Rdo_Base
$fields array Array of field names => initial values.
리턴 Horde_Rdo_Base The newly created object.

delete() 공개 메소드

Deletes a record from the backend. $object can be either a primary key, an Rdo_Query object, or an Rdo object.
public delete ( string | Horde_Rdo_Base | Horde_Rdo_Query $object ) : integer
$object string | Horde_Rdo_Base | Horde_Rdo_Query The Rdo object, Horde_Rdo_Query, or unique id to delete.
리턴 integer Number of objects deleted.

exists() 공개 메소드

Check if at least one object matches $query.
public exists ( mixed $query ) : boolean
$query mixed Either a primary key, an array of keys => values, or a Horde_Rdo_Query object.
리턴 boolean True or false.

find() 공개 메소드

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 find ( $arg = null )

findOne() 공개 메소드

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 findOne ( $arg = null )

map() 공개 메소드

Create an instance of $this->_classname from a set of data.
public map ( array $fields = [] ) : Horde_Rdo_Base
$fields array Field names/default values for the new object.
리턴 Horde_Rdo_Base An instance of $this->_classname with $fields as initial data.

mapFields() 공개 메소드

Update an instance of $this->_classname from a set of data.
public mapFields ( Horde_Rdo_Base $object, array $fields = [] )
$object Horde_Rdo_Base The object to update
$fields array Field names/default values for the object

mapperToEntity() 공개 메소드

Transform this mapper's class name to an entity class name.
public mapperToEntity ( ) : string
리턴 string A Horde_Rdo_Base concrete class name if the class exists, else null.

mapperToTable() 공개 메소드

Transform this mapper's class name to a database table name.
public mapperToTable ( ) : string
리턴 string The database table name.

removeRelation() 공개 메소드

- For one-to-one and one-to-many relations, simply sets the relation field to 0. - For many-to-many, either deletes all relations to this object or just the relation to a given peer object. - Performs a no-op if the peer is already unrelated. This is a proxy to the mapper's removeRelation method.
public removeRelation ( string $relationship, Horde_Rdo_Base $ours, Horde_Rdo_Base $theirs = null ) : integer
$relationship string The relationship key in the mapper.
$ours Horde_Rdo_Base The object from this mapper.
$theirs Horde_Rdo_Base The object to remove from the relation.
리턴 integer the number of affected relations

setFactory() 공개 메소드

If called without arguments, detaches the mapper from factory
public setFactory ( Horde_Rdo_Factory $factory = null ) : Horde_Rdo_Mapper
$factory Horde_Rdo_Factory A Factory instance or null
리턴 Horde_Rdo_Mapper this mapper

sortBy() 공개 메소드

Set a default sort rule for all queries done with this Mapper.
public sortBy ( string $sort )
$sort string SQL sort fragment, such as 'updated DESC'

tableToMapper() 공개 메소드

Transform a table name to a mapper class name.
public tableToMapper ( string $table ) : Horde_Rdo_Mapper
$table string The database table name to look up.
리턴 Horde_Rdo_Mapper A new Mapper instance if it exists, else null.

update() 공개 메소드

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.
public update ( string | Rdo $object, array $fields = null ) : integer
$object string | Rdo The Rdo instance or unique id to update.
$fields array If passing a unique id, the array of field properties to set for $object.
리턴 integer Number of objects updated.

프로퍼티 상세

$_classname 보호되어 있는 프로퍼티

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.
protected string $_classname
리턴 string

$_defaultSort 보호되어 있는 프로퍼티

Default sorting rule to use for all queries made with this mapper. This is a SQL ORDER BY fragment (without 'ORDER BY').
protected string $_defaultSort
리턴 string

$_factory 보호되어 있는 프로퍼티

The caching factory, if used
protected Horde_Rdo_Factory $_factory
리턴 Horde_Rdo_Factory

$_lazyFields 보호되어 있는 프로퍼티

Fields that should only be read from the database when they are accessed.
protected array $_lazyFields
리턴 array

$_lazyRelationships 보호되어 있는 프로퍼티

Relationships that should only be read from the database when they are accessed.
protected array $_lazyRelationships
리턴 array

$_relationships 보호되어 있는 프로퍼티

Relationships for this entity.
protected array $_relationships
리턴 array

$_setTimestamps 보호되어 있는 프로퍼티

Timestamps are always GMT for portability.
protected bool $_setTimestamps
리턴 boolean

$_tableDefinition 보호되어 있는 프로퍼티

The definition of the database table (or view, etc.) that holds this Mapper's objects.
protected Horde_Db_Adapter_Base_TableDefinition $_tableDefinition
리턴 Horde_Db_Adapter_Base_TableDefinition