mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-18 23:43:19 +08:00
Fixes #717: Added ActiveRecord::hasAttribute()
This commit is contained in:
@@ -535,6 +535,16 @@ class ActiveRecord extends Model
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value indicating whether the model has an attribute with the specified name.
|
||||
* @param string $name the name of the attribute
|
||||
* @return boolean whether the model has an attribute with the specified name.
|
||||
*/
|
||||
public function hasAttribute($name)
|
||||
{
|
||||
return isset($this->_attributes[$name]) || isset($this->getTableSchema()->columns[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the old attribute values.
|
||||
* @return array the old attribute values (name-value pairs)
|
||||
|
||||
Reference in New Issue
Block a user