I am creating one common function in one model. This model will be extended to all other models.
Now i want something like below: I want to check weather the model have createdDate field or not. Below code is not working.
public function beforeSave()
{
if(isset($this->createdDate))
die('this model have createdDate field');
else
die('this model does not have createdDate field');
}
I have used it as below. But it is giving me false even createdDate exist.
class MasterAdmin extends CActiveRecord
{
public function beforeSave()
{
echo '<pre>';
var_dump(property_exists($this, 'createdDate'));
exit;
}
}
property_exists will only check that class’s public variable. But here i have extended CActiveRecord class. So database’s field will dynamically added, so i am not sure how to check this condition.