Difference between #2 and #3 of
Creating a Simple CRUD App With Yii2 (Revised 12/20/2013)

Revision #3 has been created by Ivo Renkema on Jun 6, 2013, 7:13:50 PM with the memo:

added $this->updated = new Expression('NOW()'); to final method definition of ::beforeSave()
« previous (#2) next (#4) »

Changes

Title unchanged

Creating a Simple CRUD App With Yii2

Category unchanged

Tutorials

Yii version unchanged

Tags unchanged

yii2, tutorial, howto

Content changed

[...]
```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.
[...]
7 6
21 followers
Viewed: 304 404 times
Version: 2.0
Category: Tutorials
Last updated by: Vivek
Created on: May 4, 2013
Last updated: 10 years ago
Update Article

Revisions

View all history