From 6823fdedaf4153f7fb77cc34037d6a57de5230c7 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sun, 4 Aug 2013 07:59:28 -0400 Subject: [PATCH] Fixes #717: Added ActiveRecord::hasAttribute() --- framework/yii/db/ActiveRecord.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/framework/yii/db/ActiveRecord.php b/framework/yii/db/ActiveRecord.php index 5265a81..6e42106 100644 --- a/framework/yii/db/ActiveRecord.php +++ b/framework/yii/db/ActiveRecord.php @@ -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. * @return array the old attribute values (name-value pairs) */