Home > Article > Backend Development > Yii Framework Official Guide Series 8 - Basics: Models
A model is an instance of CModel or its subclass. Models are used to hold data and the business logic associated with it.
Models are separate data objects. It can be a row in a data table, or a user-entered form. Each field of the data object corresponds to an attribute in the model. Each attribute has a label and can be verified through a series of rules.
Yii implements two types of models: form model and Active Record. Both inherit from the same base class CModel.
The form model is an instance of CFormModel. The form model is used to hold data obtained from the user's input. This data is often acquired, used, and then discarded. For example, in a login page, we can use the form model to represent the username and password information provided by the end user. For more details, please refer to the usage form.
Active Record (AR) is a design pattern for abstracting database access in an object-oriented style. Each AR object is an instance of CActiveRecord or one of its subclasses. Represents a row in the data table. The fields in the row correspond to properties in the AR object.
The above is the Yii Framework Official Guide Series 8 - Basic Knowledge: Model Content. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!