I have an application that allows a user to import/enter information, which gets saved to the MySQL database using a Yii active record, and I have a few users who copy/paste text that has Microsoft smart quotes. This is an issue when the data is parsed on the iPhone implementation of the site, so I need a way to get rid of all the smart quotes everywhere.
I found a php function that will remove these characters from a piece of text, but I was wondering if there is a way in Yii to have the function get called every time text is saved to the database.
You can extend
CActiveRecordoverriding beforeSave method in the following manner:This one will remove magic quotes for all attributes declared in active record. As an alternative you can override beforeValidate method instead of
beforeSaveto remove quotes just before validation.