Commit 6823fded by Qiang Xue

Fixes #717: Added ActiveRecord::hasAttribute()

parent 9d8c0968
...@@ -536,6 +536,16 @@ class ActiveRecord extends Model ...@@ -536,6 +536,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. * Returns the old attribute values.
* @return array the old attribute values (name-value pairs) * @return array the old attribute values (name-value pairs)
*/ */
......
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