You can extend CActiveRecord
overriding beforeSave method in the following manner:
class ActiveRecord extends CActiveRecord
{
protected function removeMagicQuotes($value)
{
return your_function_remove_magic_quotes($value);
}
protected function beforeSave()
{
$attributes = array_keys($this->getAttributes());
foreach ($attributes as $attribute)
$this->$attribute = $this->removeMagicQuotes($this->$attribute);
return parent::beforeSave();
}
}
This one will remove magic quotes for all attributes declared in active record. As an alternative you can override beforeValidate method instead of beforeSave
to remove quotes just before validation.