Quick CakePHP Model CheatSheet

Got this today from a friend of mine today, Juan, from CakePHP.org Brasil. When I asked where he got this from he basically said: “cake/libs/model/model.php”. Still the best book.

This is how you can “bind” your models based on what each one has as keys.

belongsTo‘ => array(‘className’, ‘foreignKey’, ‘conditions’, ‘fields’, ‘order’, ‘counterCache’),

hasOne‘ => array(‘className’, ‘foreignKey’,’conditions’, ‘fields’,’order’, ‘dependent’),

hasMany‘ => array(‘className’, ‘foreignKey’, ‘conditions’, ‘fields’, ‘order’, ‘limit’, ‘offset’, ‘dependent’, ‘exclusive’, ‘finderQuery’, ‘counterQuery’),

hasAndBelongsToMany‘ => array(‘className’, ‘joinTable’, ‘with’, ‘foreignKey’, ‘associationForeignKey’, ‘conditions’, ‘fields’, ‘order’, ‘limit’, ‘offset’, ‘unique’, ‘finderQuery’, ‘deleteQuery’, ‘insertQuery’)


About mcloide

Making things simpler, just check: http://www.mcloide.com View all posts by mcloide

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: