PHP Class Prado\Data\ActiveRecord\Relations\TActiveRecordRelation

Since: 3.1
ファイルを表示 Open project: pradosoft/prado

Public Methods

Method Description
__call ( $method, $args ) : mixed 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.
__construct ( TActiveRecordRelationContext $context, $criteria )
fetchResultsInto ( $obj ) : boolean Fetch results for current relationship.
getRelationForeignKeys ( ) : array

Protected Methods

Method Description
collectForeignObjects ( &$results )
findForeignKeys ( $from, TActiveRecord $matchesRecord, $loose = false ) : array Returns foreign keys in $fromRecord with source column names as key and foreign column names in the corresponding $matchesRecord as value.
findForeignObjects ( $fields, $indexValues ) : TActiveRecord[] Fetches the foreign objects using TActiveRecord::findAllByIndex()
getContext ( ) : TActiveRecordRelationContext
getCriteria ( ) : TActiveRecordCriteria
getIndexValues ( $keys, $results ) : array Obtain the foreign key index values from the results.
getObjectHash ( $obj, $properties ) : string
getSourceRecord ( ) : TActiveRecord
populateResult ( &$results, $properties, &$fkObjects, $fields ) Populate the results with the foreign objects found.
setObjectProperty ( $source, $properties, &$collections ) Sets the foreign objects to the given property on the source object.
setResultCollection ( array &$results, array &$collections, $properties ) Populates the result array with foreign objects (matched using foreign key hashed property values).

Private Methods

Method Description
getFkFields ( $fkeys ) Find matching foreign key fields from the 3rd element of an entry in TActiveRecord::$RELATION.

Method Details

__call() public method

Multiple relationship calls can be chain together.
public __call ( $method, $args ) : mixed
return mixed TActiveRecord or array of TActiveRecord results depending on the method called.

__construct() public method

public __construct ( TActiveRecordRelationContext $context, $criteria )
$context TActiveRecordRelationContext

collectForeignObjects() abstract protected method

abstract protected collectForeignObjects ( &$results )

fetchResultsInto() public method

Fetch results for current relationship.
public fetchResultsInto ( $obj ) : boolean
return boolean always true.

findForeignKeys() protected method

The method returns the first matching foreign key between these 2 records.
protected findForeignKeys ( $from, TActiveRecord $matchesRecord, $loose = false ) : array
$matchesRecord Prado\Data\ActiveRecord\TActiveRecord
return array foreign keys with source column names as key and foreign column names as value.

findForeignObjects() protected method

Fetches the foreign objects using TActiveRecord::findAllByIndex()
protected findForeignObjects ( $fields, $indexValues ) : TActiveRecord[]
return Prado\Data\ActiveRecord\TActiveRecord[] foreign objects.

getContext() protected method

protected getContext ( ) : TActiveRecordRelationContext
return TActiveRecordRelationContext

getCriteria() protected method

protected getCriteria ( ) : TActiveRecordCriteria
return TActiveRecordCriteria

getIndexValues() protected method

Obtain the foreign key index values from the results.
protected getIndexValues ( $keys, $results ) : array
return array foreign key index values.

getObjectHash() protected method

protected getObjectHash ( $obj, $properties ) : string
return string object hash using crc32 and serialize.

getRelationForeignKeys() abstract public method

Since: 3.1.2
abstract public getRelationForeignKeys ( ) : array
return array foreign key field names as key and object properties as value.

getSourceRecord() protected method

protected getSourceRecord ( ) : TActiveRecord
return Prado\Data\ActiveRecord\TActiveRecord

populateResult() protected method

Populate the results with the foreign objects found.
protected populateResult ( &$results, $properties, &$fkObjects, $fields )

setObjectProperty() protected method

Sets the foreign objects to the given property on the source object.
protected setObjectProperty ( $source, $properties, &$collections )

setResultCollection() protected method

Populates the result array with foreign objects (matched using foreign key hashed property values).
protected setResultCollection ( array &$results, array &$collections, $properties )
$results array
$collections array