Fixes #717: Added ActiveRecord::hasAttribute()

This commit is contained in:
Qiang Xue
2013-08-04 07:59:28 -04:00
parent 9d8c096832
commit 6823fdedaf

View File

@@ -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. * Returns the old attribute values.
* @return array the old attribute values (name-value pairs) * @return array the old attribute values (name-value pairs)