Class TActiveRecordRelation

Description

Base class for active record relationships.

Located in /Data/ActiveRecord/Relations/TActiveRecordRelation.php (line 26)


	
			
Direct descendents
Class Description
TActiveRecordBelongsTo Implements the foreign key relationship (TActiveRecord::BELONGS_TO) between the source objects and the related foreign object. Consider the entity relationship between a Team and a Player.
TActiveRecordHasMany Implements TActiveRecord::HAS_MANY relationship between the source object having zero or more foreign objects. Consider the entity relationship between a Team and a Player.
TActiveRecordHasManyAssociation Implements the M-N (many to many) relationship via association table.
TActiveRecordHasOne TActiveRecordHasOne models the object relationship that a record (the source object) property is an instance of foreign record object having a foreign key related to the source object. The HAS_ONE relation is very similar to the HAS_MANY relationship (in fact, it is equivalent in the entities relationship point of view).
Method Summary
TActiveRecordRelation __construct (TActiveRecordRelationContext $context, mixed $criteria)
void collectForeignObjects (mixed &$results)
boolean fetchResultsInto (mixed $obj)
array findForeignKeys (mixed $from, TActiveRecord $matchesRecord, [mixed $loose = false], TActiveRecord $fromRecord)
TActiveRecord[] findForeignObjects (array $fields, array $indexValues)
array getIndexValues (array $keys, array $results)
string getObjectHash (mixed $obj, array $properties)
void populateResult (array &$results, array $properties, array &$fkObjects, array $fields)
void setObjectProperty (TActiveRecord $source, array $properties, array &$collections)
void setResultCollection (array &$results, array &$collections, array $properties)
mixed __call (string $method, array $args)
Methods
Constructor __construct (line 31)
  • access: public
TActiveRecordRelation __construct (TActiveRecordRelationContext $context, mixed $criteria)
collectForeignObjects (line 61)
  • access: protected
  • abstract:
void collectForeignObjects (mixed &$results)

Redefined in descendants as:
fetchResultsInto (line 95)

Fetch results for current relationship.

  • return: always true.
  • access: public
boolean fetchResultsInto (mixed $obj)
findForeignKeys (line 109)

Returns foreign keys in $fromRecord with source column names as key and foreign column names in the corresponding $matchesRecord as value.

The method returns the first matching foreign key between these 2 records.

  • return: foreign keys with source column names as key and foreign column names as value.
  • access: protected
array findForeignKeys (mixed $from, TActiveRecord $matchesRecord, [mixed $loose = false], TActiveRecord $fromRecord)
findForeignObjects (line 177)

Fetches the foreign objects using TActiveRecord::findAllByIndex()

  • return: foreign objects.
  • access: protected
TActiveRecord[] findForeignObjects (array $fields, array $indexValues)
  • array $fields: field names
  • array $indexValues: foreign key index values.
getContext (line 40)
  • access: protected
getCriteria (line 48)
  • access: protected
TActiveRecordCriteria getCriteria ()
getIndexValues (line 189)

Obtain the foreign key index values from the results.

  • return: foreign key index values.
  • access: protected
array getIndexValues (array $keys, array $results)
  • array $keys: property names
  • array $results: TActiveRecord results
getObjectHash (line 163)
  • return: object hash using crc32 and serialize.
  • access: protected
string getObjectHash (mixed $obj, array $properties)
  • mixed $obj: object or array to be hashed
  • array $properties: name of property for hashing the properties.
getRelationForeignKeys (line 138)
  • return: foreign key field names as key and object properties as value.
  • access: public
  • abstract:
  • since: 3.1.2
array getRelationForeignKeys ()

Redefined in descendants as:
getSourceRecord (line 56)
  • access: protected
TActiveRecord getSourceRecord ()
populateResult (line 211)

Populate the results with the foreign objects found.

  • access: protected
void populateResult (array &$results, array $properties, array &$fkObjects, array $fields)
  • array &$results: source results
  • array $properties: source property names
  • array &$fkObjects: foreign objects
  • array $fields: foreign object field names.
setObjectProperty (line 242)

Sets the foreign objects to the given property on the source object.

  • access: protected
void setObjectProperty (TActiveRecord $source, array $properties, array &$collections)
  • TActiveRecord $source: source object.
  • array $properties: source properties
  • array &$collections: foreign objects.

Redefined in descendants as:
setResultCollection (line 225)

Populates the result array with foreign objects (matched using foreign key hashed property values).

  • access: protected
void setResultCollection (array &$results, array &$collections, array $properties)
  • array $results
  • array $collections
  • array $properties: property names
__call (line 74)

Dispatch the method calls to the source record finder object. When an instance of TActiveRecord or an array of TActiveRecord is returned the corresponding foreign objects are also fetched and assigned.

Multiple relationship calls can be chain together.

  • return: TActiveRecord or array of TActiveRecord results depending on the method called.
  • access: public
mixed __call (string $method, array $args)
  • string $method: method name called
  • array $args: method arguments

Documentation generated on Mon, 21 Apr 2008 11:29:56 -0400 by phpDocumentor 1.3.0RC4