Chapter 6. Models

Table of Contents

1. Model Functions
1.1. User-Defined Functions
1.2. Retrieving Your Data
1.3. Saving Your Data
1.4. Model Callbacks
2. Model Variables
3. Associations

What is a model? It is the M of the MVC pattern.

What does it do? It separates domain logic from the presentation, isolating application logic.

A model is generally an access point to the database, and more specifically, to a certain table in the database. By default, each model uses the table who's name is plural of its own, i.e. a 'User' model uses the 'users' table. Models can also contain data validation rules, association information, and methods specific to the table it uses.