Populate Model From Serialized Array

I’m building a functionality whereby users can edit their profile, but the changes are first sent to admin for approval. In the meantime the current profile data remains on the site.

Now usually something like this can be accomplished by storing a ‘duplicate’ row in the database, with a flag set to ‘pending’. However, I prefer not to use this approach, as the profile data is stored across several tables, including one which contains multiple category selections

Somebody has advised me that the best way to do this would be to store the changes as a serialized array in the same row. This should be easy enough to do for saving the record, but how can I then use this data to populate a model?

The idea is that the admin can view / edit the changes before approving them, and users can make further edits to their edited data whilst it is awaiting approval. Therefore it would need the same functionality as an ActiveRecord, for example validation rules. What is the best way to go about this?




$user = User::model()->populateRecord(unserialize('serialized array'));



Thanks Tsunami, I will try that. By the way would that allow me to store relational data? For example when a user decides to update their category selections, how would I store these? Currently I have a separate table that stores the category selections.

Profile Model:


'categories'=>array(self::HAS_MANY, 'Category', 'profile_id'),

Anybody got any idea about this?