From be7deeed610871839ba166a5d4c8237e5cdbe864 Mon Sep 17 00:00:00 2001 From: xue <> Date: Tue, 4 Dec 2007 18:59:48 +0000 Subject: Active Record now supports query criteria for implicitly declared related properties --- .../Relations/TActiveRecordRelationContext.php | 36 ++++++++++++++++------ 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'framework/Data/ActiveRecord/Relations/TActiveRecordRelationContext.php') diff --git a/framework/Data/ActiveRecord/Relations/TActiveRecordRelationContext.php b/framework/Data/ActiveRecord/Relations/TActiveRecordRelationContext.php index 28d80683..ff6d9554 100644 --- a/framework/Data/ActiveRecord/Relations/TActiveRecordRelationContext.php +++ b/framework/Data/ActiveRecord/Relations/TActiveRecordRelationContext.php @@ -68,14 +68,6 @@ class TActiveRecordRelationContext return $this->_record; } - /** - * @return string foreign record class name. - */ - public function getForeignRecordClass() - { - return $this->_relation[1]; - } - /** * @return array foreign key of this relations, the keys is dependent on the * relationship type. @@ -96,6 +88,14 @@ class TActiveRecordRelationContext return $this->_relation[0]; } + /** + * @return string foreign record class name. + */ + public function getForeignRecordClass() + { + return $this->_relation[1]; + } + /** * @return string foreign key field names, comma delimited. * @since 3.1.2 @@ -105,6 +105,24 @@ class TActiveRecordRelationContext return $this->_relation[2]; } + /** + * @return string the query condition for the relation as specified in RELATIONS + * @since 3.1.2 + */ + public function getCondition() + { + return isset($this->_relation[3])?$this->_relation[3]:null; + } + + /** + * @return array the query parameters for the relation as specified in RELATIONS + * @since 3.1.2 + */ + public function getParameters() + { + return isset($this->_relation[4])?$this->_relation[4]:array(); + } + /** * @return boolean true if the 3rd element of an TActiveRecord::$RELATION entry is set. * @since 3.1.2 @@ -156,7 +174,7 @@ class TActiveRecordRelationContext $this->_property, get_class($this->_record), 'RELATIONS'); } if($criteria===null) - $criteria = new TActiveRecordCriteria; + $criteria = new TActiveRecordCriteria($this->getCondition(), $this->getParameters()); switch($this->getRelationType()) { case TActiveRecord::HAS_MANY: -- cgit v1.2.3