- Home
- About
- Testimonials
- Demos
- Download
- Documentation
- Blogs
- Forum
- Support

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: TActiveRecordBelongsTo TActiveRecordHasMany TActiveRecordHasManyAssociation TActiveRecordHasOne TActiveRecordRelation TActiveRecordRelationContext |
Keyword
# Class TActiveRecordRelation
#### Direct Known Sub-classes: TActiveRecordHasOne , TActiveRecordBelongsTo , TActiveRecordHasManyAssociation , TActiveRecordHasMany 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 | getContext ()
protected TActiveRecordCriteria | getCriteria ()
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 | getRelationForeignKeys ()
protected TActiveRecord | getSourceRecord ()
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 | $fields | field names
array | $indexValues | foreign 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 | $keys | property names
array | $results | TActiveRecord results
Output
array | foreign key index values.
Exception
## getObjectHash
protected string getObjectHash | (mixed $obj , array $properties )
Input
mixed | $obj | object or array to be hashed
array | $properties | name 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 | &$results | source results
array | $properties | source property names
array | &$fkObjects | foreign objects
array | $fields | foreign 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 | $source | source object.
array | $properties | source properties
array | &$collections | foreign 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 | $properties | property 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 | $method | method name called
array | $args | method arguments
Output
mixed | TActiveRecord or array of TActiveRecord results depending on the method called.
Exception