summaryrefslogtreecommitdiff
path: root/framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php
diff options
context:
space:
mode:
authorwei <>2007-04-30 03:44:49 +0000
committerwei <>2007-04-30 03:44:49 +0000
commitea0601cdd4a732fc15b83104a47788989bb004b3 (patch)
tree3366e670cc904001c02f71f969fcedd90129f6a9 /framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php
parent970057f16ae4ca2a85ad6710c0d6e371f0bf003d (diff)
Reverted TActiveRecord::populateObject to protected
Diffstat (limited to 'framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php')
-rw-r--r--framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php47
1 files changed, 35 insertions, 12 deletions
diff --git a/framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php b/framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php
index f1e8fa60..38455309 100644
--- a/framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php
+++ b/framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php
@@ -1,6 +1,30 @@
<?php
+/**
+ * TActiveRecordRelation class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2007 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package System.Data.ActiveRecord.Relations
+ */
+
+/**
+ * Load active record relationship context.
+ */
Prado::using('System.Data.ActiveRecord.Relations.TActiveRecordRelationContext');
+/**
+ * Base class for active record relationships.
+ *
+ * description
+ *
+ * @author Wei Zhuo <weizho[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Data.ActiveRecord.Relations
+ * @since 3.1
+ */
abstract class TActiveRecordRelation
{
private $_context;
@@ -28,11 +52,10 @@ abstract class TActiveRecordRelation
/**
* Dispatch the method calls to the source record finder object. When
- * the results are returned as array or is an instance of TActiveRecord we
- * will fetch the corresponding foreign objects with an sql query and populate
- * the results obtained earlier.
+ * an instance of TActiveRecord or an array of TActiveRecord is returned
+ * the corresponding foreign objects are also fetched and assigned.
*
- * Allows chaining multiple relation handlers.
+ * Multiple relationship calls can be chain together.
*
* @param string method name called
* @param array method arguments
@@ -106,7 +129,7 @@ abstract class TActiveRecordRelation
/**
* Obtain the foreign key index values from the results.
* @param array property names
- * @param array|TActiveRecord TActiveRecord results
+ * @param array TActiveRecord results
* @return array foreign key index values.
*/
protected function getIndexValues($keys, $results)
@@ -134,14 +157,16 @@ abstract class TActiveRecordRelation
{
$collections=array();
foreach($fkObjects as $fkObject)
- {
- $hash = $this->getObjectHash($fkObject, $fields);
- $collections[$hash][]=$fkObject;
- }
-
+ $collections[$this->getObjectHash($fkObject, $fields)][]=$fkObject;
$this->setResultCollection($results, $collections, $properties);
}
+ /**
+ * Populates the result array with foreign objects (matched using foreign key hashed property values).
+ * @param array $results
+ * @param array $collections
+ * @param array property names
+ */
protected function setResultCollection(&$results, &$collections, $properties)
{
if(is_array($results))
@@ -150,9 +175,7 @@ abstract class TActiveRecordRelation
$this->setObjectProperty($results[$i], $properties, $collections);
}
else
- {
$this->setObjectProperty($results, $properties, $collections);
- }
}
/**