Packages:
default
System
System.Caching
System.Collections
System.Data
System.Data.ActiveRecord
System.Data.ActiveRecord.Relations
System.Data.ActiveRecord.Scaffold
System.Data.ActiveReecord.Scaffold.InputBuilder
System.Data.Commom.Sqlite
System.Data.Common
System.Data.Common.Mssql
System.Data.Common.Mysql
System.Data.Common.Oracle
System.Data.Common.Pgsql
System.Data.Common.Sqlite
System.Data.DataGateway
System.Data.SqlMap
System.Data.SqlMap.Configuration
System.Data.SqlMap.Statements
System.Exceptions
System.I18N
System.IO
System.Security
System.Util
System.Web
System.Web.Services
System.Web.UI
System.Web.UI.ActiveControls
System.Web.UI.WebControls
System.Web.UI.WebControls.assets
System.Xml


Classes:
Keyword

Class TActiveRecordRelation


Base class for active record relationships.

Since: 3.1
Author: Wei Zhuo <weizho[at]gmail[dot]com>

Constructor Summary
public
__construct Array

Method Summary
protected  abstract  void
collectForeignObjects ( mixed &$results)
boolean
fetchResultsInto ( mixed $obj)
Fetch results for current relationship.
protected  array
findForeignKeys ( mixed $from, TActiveRecord $matchesRecord, mixed $loose, TActiveRecord $fromRecord)
Returns foreign keys in $fromRecord with source column names as key and foreign column names in the corresponding $matchesRecord as value.
protected  TActiveRecord[]
findForeignObjects ( array $fields, array $indexValues)
Fetches the foreign objects using TActiveRecord::findAllByIndex()
protected  TActiveRecordRelationContext
protected  TActiveRecordCriteria
protected  array
getIndexValues ( array $keys, array $results)
Obtain the foreign key index values from the results.
protected  string
getObjectHash ( mixed $obj, array $properties)
abstract  array
protected  TActiveRecord
protected  void
populateResult ( array &$results, array $properties, array &$fkObjects, array $fields)
Populate the results with the foreign objects found.
protected  void
setObjectProperty ( TActiveRecord $source, array $properties, array &$collections)
Sets the foreign objects to the given property on the source object.
protected  void
setResultCollection ( array &$results, array &$collections, array $properties)
Populates the result array with foreign objects (matched using foreign key hashed property values).
mixed
__call ( string $method, array $args)
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.

Constructor Details

__construct

public __construct Array


Method Details

collectForeignObjects

protected abstract void collectForeignObjects (mixed &$results )

Input
mixed&$results
Output
Exception

fetchResultsInto

public boolean fetchResultsInto (mixed $obj )

Fetch results for current relationship.

Input
mixed$obj
Output
boolean always true.
Exception

findForeignKeys

protected array findForeignKeys (mixed $from , TActiveRecord $matchesRecord , mixed $loose , TActiveRecord $fromRecord )

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.

Input
mixed$from
TActiveRecord$matchesRecord
mixed$loose
TActiveRecord$fromRecord
Output
array foreign keys with source column names as key and foreign column names as value.
Exception

findForeignObjects

protected TActiveRecord[] findForeignObjects (array $fields , array $indexValues )

Fetches the foreign objects using TActiveRecord::findAllByIndex()

Input
array$fieldsfield names
array$indexValuesforeign key index values.
Output
TActiveRecord[] foreign objects.
Exception

getContext

protected TActiveRecordRelationContext getContext ()

Output
Exception

getCriteria

protected TActiveRecordCriteria getCriteria ()

Output
Exception

getIndexValues

protected array getIndexValues (array $keys , array $results )

Obtain the foreign key index values from the results.

Input
array$keysproperty names
array$resultsTActiveRecord results
Output
array foreign key index values.
Exception

getObjectHash

protected string getObjectHash (mixed $obj , array $properties )

Input
mixed$objobject or array to be hashed
array$propertiesname of property for hashing the properties.
Output
string object hash using crc32 and serialize.
Exception

getRelationForeignKeys

public abstract array getRelationForeignKeys ()

Output
array foreign key field names as key and object properties as value.
Exception

getSourceRecord

protected TActiveRecord getSourceRecord ()

Output
Exception

populateResult

protected void populateResult (array &$results , array $properties , array &$fkObjects , array $fields )

Populate the results with the foreign objects found.

Input
array&$resultssource results
array$propertiessource property names
array&$fkObjectsforeign objects
array$fieldsforeign object field names.
Output
Exception

setObjectProperty

protected void setObjectProperty (TActiveRecord $source , array $properties , array &$collections )

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

Input
TActiveRecord$sourcesource object.
array$propertiessource properties
array&$collectionsforeign objects.
Output
Exception

setResultCollection

protected void setResultCollection (array &$results , array &$collections , array $properties )

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

Input
array&$results
array&$collections
array$propertiesproperty names
Output
Exception

__call

public mixed __call (string $method , array $args )

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.

Input
string$methodmethod name called
array$argsmethod arguments
Output
mixed TActiveRecord or array of TActiveRecord results depending on the method called.
Exception