summaryrefslogtreecommitdiff
path: root/framework/Data/ActiveRecord/Relations/TActiveRecordRelationContext.php
diff options
context:
space:
mode:
authorwei <>2007-05-07 04:17:37 +0000
committerwei <>2007-05-07 04:17:37 +0000
commiteab6bb13b9efb3e1c6d725368368de4d74b00946 (patch)
tree57aa3462b6f18ad190527483e753dc148971bc63 /framework/Data/ActiveRecord/Relations/TActiveRecordRelationContext.php
parente91ac8550a4e6dfa255874860f108935841c16f6 (diff)
Update Active Record docs.
Diffstat (limited to 'framework/Data/ActiveRecord/Relations/TActiveRecordRelationContext.php')
-rw-r--r--framework/Data/ActiveRecord/Relations/TActiveRecordRelationContext.php13
1 files changed, 11 insertions, 2 deletions
diff --git a/framework/Data/ActiveRecord/Relations/TActiveRecordRelationContext.php b/framework/Data/ActiveRecord/Relations/TActiveRecordRelationContext.php
index 12f2a874..16b29861 100644
--- a/framework/Data/ActiveRecord/Relations/TActiveRecordRelationContext.php
+++ b/framework/Data/ActiveRecord/Relations/TActiveRecordRelationContext.php
@@ -182,7 +182,6 @@ class TActiveRecordRelationContext
*/
public function updateAssociatedRecords($updateBelongsTo=false)
{
- Prado::using('System.Data.ActiveRecord.Relations.TActiveRecordRelationCommand');
$success=true;
foreach($this->getRecordRelationships() as $property=>$relation)
{
@@ -190,7 +189,7 @@ class TActiveRecordRelationContext
if(($updateBelongsTo && $belongsTo) || (!$updateBelongsTo && !$belongsTo))
{
$obj = $this->getSourceRecord();
- if(!empty($obj->{$property}))
+ if(!$this->isEmptyFkObject($obj->{$property}))
{
$context = new self($this->getSourceRecord(),$property);
$success = $context->getRelationHandler()->updateAssociatedRecords() && $success;
@@ -199,6 +198,16 @@ class TActiveRecordRelationContext
}
return $success;
}
+
+ protected function isEmptyFkObject($obj)
+ {
+ if(is_object($obj))
+ return $obj instanceof TList ? $obj->count() === 0 : false;
+ else if(is_array($obj))
+ return count($obj)===0;
+ else
+ return empty($obj);
+ }
}
?> \ No newline at end of file