From a042d20c22a302945ffe1d2144e560378822ded5 Mon Sep 17 00:00:00 2001 From: Niko Wicaksono Date: Sat, 10 Aug 2013 02:31:49 +0700 Subject: [PATCH] Use `hasAttribute()` instead to avoid code duplication --- framework/yii/db/ActiveRecord.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/yii/db/ActiveRecord.php b/framework/yii/db/ActiveRecord.php index d385bed..5aa9807 100644 --- a/framework/yii/db/ActiveRecord.php +++ b/framework/yii/db/ActiveRecord.php @@ -399,7 +399,7 @@ class ActiveRecord extends Model */ public function __set($name, $value) { - if (isset($this->_attributes[$name]) || isset($this->getTableSchema()->columns[$name])) { + if ($this->hasAttribute($name)) { $this->_attributes[$name] = $value; } else { parent::__set($name, $value); @@ -562,7 +562,7 @@ class ActiveRecord extends Model */ public function setAttribute($name, $value) { - if (isset($this->_attributes[$name]) || isset($this->getTableSchema()->columns[$name])) { + if ($this->hasAttribute($name)) { $this->_attributes[$name] = $value; } else { throw new InvalidParamException(get_class($this) . ' has no attribute named "' . $name . '".');