O'Reilly logo

Mastering Yii 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

Models

In Yii1, base models and form models were two separated classes (CModel and CFormModel). In Yii2, these two classes have been consolidated into a single class, yii/base/Model. This class is used throughout Yii2 for data representation and should be our go-to class when representing data we can't represent with yii/db/ActiveRecord.

Tip

Since yii/db/ActiveRecord extends yii/base/Model, we're already familiar with the majority of methods and properties that yii/base/Model offers, such as getAttributes(), rules(), attributeLabels(), and getErrors(). Refer to the Yii2 API documentation for a complete list of all the methods supported by yii/base/Model at http://www.yiiframework.com/doc-2.0/yii-base-model.html.

Model attributes

In yii/db/ActiveRecord ...

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