How can I check whether an AR model has a certain column?


I’m trying to check if a model has a certain column

I tried using isset($model->column) but that doesn’t work

CActiveRecord’s __isset method returns false when the attribute has not yet been set, even though the column exists

	public function __isset($name)



			return true;

		else if(isset($this->getMetaData()->columns[$name]))

			return false;

		else if(isset($this->_related[$name]))

			return true;

		else if(isset($this->getMetaData()->relations[$name]))

			return $this->getRelated($name)!==null;


			return parent::__isset($name);


Is there any other way to check if a column exists?

please disregard that topic

hasAttribute does the trick

$this->getTableSchema()->getColumn(‘column’) === null ? xxx