From 4ceba82b9863f2c6323cbe00407e4bfbedbfc1cd Mon Sep 17 00:00:00 2001 From: wei <> Date: Mon, 8 Oct 2007 03:24:07 +0000 Subject: Allow active records to have multiple foreign key references to the same table. Add TXCache. --- .../ActiveRecord/Relations/TActiveRecordHasMany.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'framework/Data/ActiveRecord/Relations/TActiveRecordHasMany.php') diff --git a/framework/Data/ActiveRecord/Relations/TActiveRecordHasMany.php b/framework/Data/ActiveRecord/Relations/TActiveRecordHasMany.php index cbba3ebd..f7426862 100644 --- a/framework/Data/ActiveRecord/Relations/TActiveRecordHasMany.php +++ b/framework/Data/ActiveRecord/Relations/TActiveRecordHasMany.php @@ -1,4 +1,4 @@ -getContext()->getForeignRecordFinder(); - $fkeys = $this->findForeignKeys($fkObject, $this->getSourceRecord()); + $fkeys = $this->getRelationForeignKeys(); $properties = array_values($fkeys); $fields = array_keys($fkeys); @@ -86,6 +85,16 @@ class TActiveRecordHasMany extends TActiveRecordRelation $this->populateResult($results,$properties,$fkObjects,$fields); } + /** + * @return array foreign key field names as key and object properties as value. + * @since 3.1.2 + */ + public function getRelationForeignKeys() + { + $fkObject = $this->getContext()->getForeignRecordFinder(); + return $this->findForeignKeys($fkObject, $this->getSourceRecord()); + } + /** * Updates the associated foreign objects. * @return boolean true if all update are success (including if no update was required), false otherwise . @@ -113,5 +122,5 @@ class TActiveRecordHasMany extends TActiveRecordRelation return $success; } } - + ?> \ No newline at end of file -- cgit v1.2.3