I am newbie here, so not sure if this is basic question.
I have one database, where in all tables i have placed createdDate, updatedDate, createdIp, updatedIp fields.
Using CRUD i have generated all admin pages. Now above 4 fields are common in all models.Whenever admin add/edit any record these 4 field should be automatically added/updated. I don’t want to set it’s value in all pages.
Where can i add such code to auto capture these 4 values?
@binkabir: I have gone through the article and see how to use beforeSave() function. Now i need to write beforeSave function for all models. How can i write one common function among all models? I think i can do this by what you said:
[i]alternatively create a class that extends CActiveRecord (place it in the components directory, IMHO) while all Model classes will extend from your custom class
and override this methods i mentioned above[/i]
I have created AutoFillColumn.php file under component folder:
class AutoFillColumn extends CActiveRecord
public function beforeSave()
$_model->createdDate = new CDbExpression('NOW()');
Added it in config file:
Now what other change i need to do to auto update all "createdDate" field?