I don’t think that updateAll is made for this purpose. What I would do is a creating a function within your CActiveRecord-based object that calculates the value and call it, for example, updatePercentageChange. You could then call updatePercentageChange and save to persist the percentage_change.
I am thinking that another, easier solution would be to pull an array from the table using AR->findAll. From there, iterate it, pulling out the values, calculating them then updateByPK().
Seems like a good idea? Cant see any drawbacks to it?
beforeSave/afterSave will be called only when you save (insert or update) a single AR object. So you can modify a column value of the AR object before saving.
But updateAll() execute a single SQL to update multiple records. It does that without fetching their data into AR objects. You may update a column value using SQL functions in this case.