O'Reilly logo

Yii Project Blueprints by Charles R. Portwood II

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating models

By now, you should be familiar with using the Gii tool to create models for our newly created tables. Go ahead and create the models for Users, Reminders, and Events. After creating each model, there are several changes we need to make to each of them.

Model behaviors

The first change that will need to be made to our newly created models is the automatic setting of the created and updated timestamp. In previous chapters, we modified the beforeSave() method to do this; however, Yii provides an easier way to implement this feature that is database-agnostic and reduces the amount of code we have to add to our models. To do this, we are going to attach a behavior to each of our models.

Behaviors in Yii are objects that have methods that ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required