From eab6bb13b9efb3e1c6d725368368de4d74b00946 Mon Sep 17 00:00:00 2001 From: wei <> Date: Mon, 7 May 2007 04:17:37 +0000 Subject: Update Active Record docs. --- .../ActiveRecord/Relations/TActiveRecordRelationContext.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 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 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 -- cgit v1.2.3