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)
array findForeignKeys (mixed $from, TActiveRecord $matchesRecord, 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 30)
  • access: public
TActiveRecordRelation __construct (TActiveRecordRelationContext $context)
findForeignKeys (line 87)

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, TActiveRecord $fromRecord)
findForeignObjects (line 123)

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 38)
  • access: protected
getIndexValues (line 136)

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 109)
  • 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.
getSourceRecord (line 46)
  • access: protected
TActiveRecord getSourceRecord ()
populateResult (line 158)

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 189)

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 172)

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 62)

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 Sun, 30 Sep 2007 19:10:30 -0400 by phpDocumentor 1.3.0RC4