Creating a Simple CRUD App With Yii2 (Revised 12/20/2013)

Comparing #2 with #3

Revision #3 was created by Ivo Renkema Ivo Renkema on Jun 6, 2013, 7:13:50 PM.

added $this->updated = new Expression('NOW()'); to final method definition of ::beforeSave()

Content

[...]
```php
public function beforeSave($insert)
{
    if ($this->isNewRecord)
 
 {
 
        
$this->created = new Expression('NOW()');     }
 
    $this->updated = new Expression('NOW()');
 
    
return parent::beforeSave($insert);
}
```

Now try saving again. Our model now has validation on both the title, and content fields, and will automatically update the created and update time for you. Now lets do updating.
[...]