Revision #8 has been created by nye.cat on Jun 15, 2011, 6:04:44 PM with the memo:
Deleted 'else' in the beforeSave Example
« previous (#7) next (#9) »
Changes
Title
unchanged
How to automate timestamps in ActiveRecord models
Category
unchanged
Tutorials
Yii version
unchanged
Tags
unchanged
Content
changed
[...]
[php]
public function beforeSave() {
if ($this->isNewRecord)
$this->created = new CDbExpression('NOW()');
else
$this->modified = new CDbExpression('NOW()');
return parent::beforeSave();
}
These are simple and elegant solutions to this issue.