Commit dedad248 by Qiang Xue

Merge pull request #737 from wicaksono/master

Use `hasAttribute()` instead to avoid code duplication
parents aeb568be a042d20c
...@@ -399,7 +399,7 @@ class ActiveRecord extends Model ...@@ -399,7 +399,7 @@ class ActiveRecord extends Model
*/ */
public function __set($name, $value) public function __set($name, $value)
{ {
if (isset($this->_attributes[$name]) || isset($this->getTableSchema()->columns[$name])) { if ($this->hasAttribute($name)) {
$this->_attributes[$name] = $value; $this->_attributes[$name] = $value;
} else { } else {
parent::__set($name, $value); parent::__set($name, $value);
...@@ -562,7 +562,7 @@ class ActiveRecord extends Model ...@@ -562,7 +562,7 @@ class ActiveRecord extends Model
*/ */
public function setAttribute($name, $value) public function setAttribute($name, $value)
{ {
if (isset($this->_attributes[$name]) || isset($this->getTableSchema()->columns[$name])) { if ($this->hasAttribute($name)) {
$this->_attributes[$name] = $value; $this->_attributes[$name] = $value;
} else { } else {
throw new InvalidParamException(get_class($this) . ' has no attribute named "' . $name . '".'); throw new InvalidParamException(get_class($this) . ' has no attribute named "' . $name . '".');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment