When creating your models, there are a number of special variables you can set in order to gain access to Cake functionality:
$primaryKey
If this model relates to a database table, and the table's primary key is not named 'id', use this variable to tell Cake the name of the primary key.
$recursive
This sets the number of levels you wish Cake to fetch associated model data in find() and findAll() operations.
Imagine you have Groups which have many Users which in turn have many Articles.
Table 6.1. Model::recursive options
| $recursive = 0 | Cake fetches Group data |
| $recursive = 1 | Cake fetches a Group and its associated Users |
| $recursive = 2 | Cake fetches a Group, its associated Users, and the Users' associated Articles |
$transactional
Tells Cake whether or not to enable transactions for this model (i.e. begin/commit/rollback). Set to a boolean value. Only available for supporting databases.
$useTable
If the database table you wish to use isn't the plural form of the model name (and you don't wish to change the table name), set this variable to the name of the table you'd like this model to use.
$validate
An array used to validate the data passed to this model. See Chapter "Data Validation".
$useDbConfig
Remember the database settings you can configure in
/app/config/database.php? Use this variable to switch
between them - just use the name of the database connection variable
you've created in your database configuration file. The default is, you
guessed it, 'default'.