PHP Class Horde_Rdo_Base, horde

Inheritance: implements IteratorAggregate, implements ArrayAccess
Afficher le fichier Open project: horde/horde Class Usage Examples

Protected Properties

Свойство Type Description
$_fields array This object's fields.
$_mapper Horde_Rdo_Mapper The Horde_Rdo_Mapper instance associated with this Rdo object. The Mapper takes care of all backend access.

Méthodes publiques

Méthode Description
__clone ( ) When Rdo objects are cloned, unset the unique id that identifies them so that they can be modified and saved to the backend as new objects. If you don't really want a new object, don't clone.
__construct ( array $fields = [] ) Constructor. Can be called directly by a programmer, or is called in Horde_Rdo_Mapper::map(). Takes an associative array of initial object values.
__get ( string $field ) : mixed Fetch fields that haven't yet been loaded. Lazy-loaded fields and lazy-loaded relationships are handled this way. Once a field is retrieved, it is cached in the $_fields array so it doesn't need to be fetched again.
__isset ( string $field ) Allow using isset($rdo->foo) to check for field or relationship presence.
__set ( string $field, mixed $value ) Set a field's value.
__unset ( string $field ) Allow using unset($rdo->foo) to unset a basic field. Relationships cannot be unset in this way.
addRelation ( string $relationship, Horde_Rdo_Base $peer ) Adds a relation to one of the relationships defined in the mapper.
delete ( ) : boolean Delete this object from the backend.
getIterator ( ) : Horde_Rdo_Iterator Implement the IteratorAggregate interface. Looping over an Rdo object goes through each property of the object in turn.
getMapper ( ) : Horde_Rdo_Mapper Get a Mapper instance that can be used to manage this object. The Mapper instance can come from a few places:
hasRelation ( string $relationship, Horde_Rdo_Base $peer = null ) : boolean Checks whether a relation to a peer is defined through one of the relationships in the mapper.
offsetExists ( $field ) Implements isset() for ArrayAccess interface.
offsetGet ( $field ) Implements getter for ArrayAccess interface.
offsetSet ( $field, $value ) Implements setter for ArrayAccess interface.
offsetUnset ( $field ) Implements unset() for ArrayAccess interface.
removeRelation ( string $relationship, Horde_Rdo_Base $peer = null ) : integer Removes a relation to one of the relationships defined in the mapper.
save ( ) : boolean Save any changes to the backend.
setFields ( array $fields = [] ) Set field values for the object
setMapper ( Horde_Rdo_Mapper $mapper ) Associate this Rdo object with the Mapper instance that will manage it. Called automatically by Horde_Rdo_Mapper:map().
toArray ( boolean $lazy = false, boolean $relationships = false ) : array Converts the entity to an Array.

Méthodes protégées

Méthode Description
_fillPlaceholders ( array $query ) : array Take a query array and replace @field@ placeholders with values from this object.

Method Details

__clone() public méthode

When Rdo objects are cloned, unset the unique id that identifies them so that they can be modified and saved to the backend as new objects. If you don't really want a new object, don't clone.
public __clone ( )

__construct() public méthode

Constructor. Can be called directly by a programmer, or is called in Horde_Rdo_Mapper::map(). Takes an associative array of initial object values.
See also: Horde_Rdo_Mapper::map()
public __construct ( array $fields = [] )
$fields array Initial values for the new object.

__get() public méthode

Fetch fields that haven't yet been loaded. Lazy-loaded fields and lazy-loaded relationships are handled this way. Once a field is retrieved, it is cached in the $_fields array so it doesn't need to be fetched again.
public __get ( string $field ) : mixed
$field string The name of the field to access.
Résultat mixed The value of $field or null.

__isset() public méthode

Allow using isset($rdo->foo) to check for field or relationship presence.
public __isset ( string $field )
$field string The field name to check existence of.

__set() public méthode

Set a field's value.
public __set ( string $field, mixed $value )
$field string The field to set
$value mixed The field's new value

__unset() public méthode

Allow using unset($rdo->foo) to unset a basic field. Relationships cannot be unset in this way.
public __unset ( string $field )
$field string The field name to unset.

_fillPlaceholders() protected méthode

Take a query array and replace @field@ placeholders with values from this object.
protected _fillPlaceholders ( array $query ) : array
$query array The query to process placeholders on.
Résultat array The query with placeholders filled in.

addRelation() public méthode

- 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. This is a proxy to the mapper's addRelation() method.
public addRelation ( string $relationship, Horde_Rdo_Base $peer )
$relationship string The relationship key in the mapper.
$peer Horde_Rdo_Base The object to add the relation.

delete() public méthode

Delete this object from the backend.
public delete ( ) : boolean
Résultat boolean Success or failure.

getIterator() public méthode

Implement the IteratorAggregate interface. Looping over an Rdo object goes through each property of the object in turn.
public getIterator ( ) : Horde_Rdo_Iterator
Résultat Horde_Rdo_Iterator The Iterator instance.

getMapper() public méthode

- If the class Mapper exists, it will be used automatically. - Any Rdo instance created with Horde_Rdo_Mapper::map() will have a $mapper object set automatically. - Subclasses can override getMapper() to return the correct mapper object. - The programmer can call $rdoObject->setMapper($mapper) to provide a mapper object. A Horde_Rdo_Exception will be thrown if none of these conditions are met.
public getMapper ( ) : Horde_Rdo_Mapper
Résultat Horde_Rdo_Mapper The Mapper instance managing this object.

hasRelation() public méthode

Checks whether a relation to a peer is defined through one of the relationships in the mapper.
public hasRelation ( string $relationship, Horde_Rdo_Base $peer = null ) : boolean
$relationship string The relationship key in the mapper.
$peer Horde_Rdo_Base The object to check for the relation. If this is null, check if there is any peer for this relation.
Résultat boolean True if related.

offsetExists() public méthode

Implements isset() for ArrayAccess interface.
See also: __isset()
public offsetExists ( $field )

offsetGet() public méthode

Implements getter for ArrayAccess interface.
See also: __get()
public offsetGet ( $field )

offsetSet() public méthode

Implements setter for ArrayAccess interface.
See also: __set()
public offsetSet ( $field, $value )

offsetUnset() public méthode

Implements unset() for ArrayAccess interface.
See also: __unset()
public offsetUnset ( $field )

removeRelation() public méthode

- 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 $peer = null ) : integer
$relationship string The relationship key in the mapper
$peer Horde_Rdo_Base The object to remove from the relation
Résultat integer The number of relations affected

save() public méthode

Save any changes to the backend.
public save ( ) : boolean
Résultat boolean Success.

setFields() public méthode

Set field values for the object
See also: Horde_Rdo_Mapper::map()
public setFields ( array $fields = [] )
$fields array Initial values for the new object.

setMapper() public méthode

Associate this Rdo object with the Mapper instance that will manage it. Called automatically by Horde_Rdo_Mapper:map().
See also: Horde_Rdo_Mapper::map()
public setMapper ( Horde_Rdo_Mapper $mapper )
$mapper Horde_Rdo_Mapper The Mapper to manage this Rdo object.

toArray() public méthode

This method can be used when handing it over to Horde_Variables so that the database is not unnecessarily queried because of lazyFields/lazyRelationships.
public toArray ( boolean $lazy = false, boolean $relationships = false ) : array
$lazy boolean Whether lazy elements should be added.
$relationships boolean Whether relationships should be added.
Résultat array All selected fields and relationships.

Property Details

$_fields protected_oe property

This object's fields.
protected array $_fields
Résultat array

$_mapper protected_oe property

The Horde_Rdo_Mapper instance associated with this Rdo object. The Mapper takes care of all backend access.
See also: Horde_Rdo_Mapper
protected Horde_Rdo_Mapper $_mapper
Résultat Horde_Rdo_Mapper