summaryrefslogtreecommitdiff
path: root/framework/Data/ActiveRecord/Relations/TActiveRecordHasManyAssociation.php
diff options
context:
space:
mode:
authorwei <>2007-05-01 00:27:01 +0000
committerwei <>2007-05-01 00:27:01 +0000
commit595a0acc2554da4c4c52f065dc76893c241f2624 (patch)
tree3eb8bf5d97d733f2a4251c863a6619bb12cf7a4c /framework/Data/ActiveRecord/Relations/TActiveRecordHasManyAssociation.php
parentea0601cdd4a732fc15b83104a47788989bb004b3 (diff)
Add comments to active record relationships, add semi-colon to js files.
Diffstat (limited to 'framework/Data/ActiveRecord/Relations/TActiveRecordHasManyAssociation.php')
-rw-r--r--framework/Data/ActiveRecord/Relations/TActiveRecordHasManyAssociation.php18
1 files changed, 14 insertions, 4 deletions
diff --git a/framework/Data/ActiveRecord/Relations/TActiveRecordHasManyAssociation.php b/framework/Data/ActiveRecord/Relations/TActiveRecordHasManyAssociation.php
index a86fdffd..bb2cc583 100644
--- a/framework/Data/ActiveRecord/Relations/TActiveRecordHasManyAssociation.php
+++ b/framework/Data/ActiveRecord/Relations/TActiveRecordHasManyAssociation.php
@@ -1,4 +1,4 @@
-<?php
+<?php
/**
* Loads base active record relations class.
@@ -75,18 +75,28 @@ class TActiveRecordHasManyAssociation extends TActiveRecordRelation
$finder = $this->getContext()->getForeignRecordFinder();
$command = $this->createCommand($criteria, $foreignKeys,$indexValues,$sourceKeys);
$srcProps = array_keys($sourceKeys);
- $type = get_class($finder);
$collections=array();
foreach($command->query() as $row)
{
$hash = $this->getObjectHash($row, $srcProps);
foreach($srcProps as $column)
unset($row[$column]);
- $collections[$hash][] = $finder->populateObject($type,$row);
+ $collections[$hash][] = $this->populateObject($finder, $row);
}
$this->setResultCollection($results, $collections, array_values($sourceKeys));
}
+
+ protected function populateObject($finder, $data)
+ {
+ $registry = $finder->getRecordManager()->getObjectStateRegistry();
+ if(!is_null($obj = $registry->getCachedInstance($data, false)))
+ return $obj;
+ $gateway = $finder->getRecordManager()->getRecordGateway();
+ $type = get_class($finder);
+ $obj = new $type($data);
+ return $registry->addCachedInstance($data,$obj);
+ }
/**
* @param TSqlCriteria
@@ -145,5 +155,5 @@ class TActiveRecordHasManyAssociation extends TActiveRecordRelation
return "INNER JOIN {$refTable} ON ({$joinCondition}) AND {$index}";
}
-}
+}
?> \ No newline at end of file