我看了这里的说明http://www.yiiframework.com/doc/cookbook/14/
有个疑问,可不可以直接把以下代码写到Model里呢?
Quote
public function beforeValidate($on) {
if ($this->Owner->isNewRecord)
$this->Owner->{$this->created} = new CDbExpression('NOW()');
else
$this->Owner->{$this->modified} = new CDbExpression('NOW()');
return true;
}
直接写到Model里不是也一样可以实现吗?为什么要用CActiveRecordbehavior呢?