Professional Documents
Culture Documents
Cakephp1.2 Model Associations 1
Cakephp1.2 Model Associations 1
2
CakePHP Model Associations Cheat Sheet
$hasMany – one to many $hasAndBelongsToMany – many to many
array( array(
'UniqueName' => array( 'UniqueName' => array(
'className' => 'thatClassName', 'className' => 'thatClassName',
'foreignKey' => 'this_fk_id', 'joinTable' => 'join(s)_table(s)',
'conditions' => array( 'with' => 'JoiningClassName',
'That.field' => 'somevalue' 'foreignKey' => 'this_id',
), 'associationForeignKey'=> 'that_id',
'order' => 'That.field DESC', 'unique'=> true,
'limit' => '5', 'conditions' => array(
'fields' => 'That.fields', 'That.field' => 'somevalue'
'offset' => 0, ),
'dependent'=> true, 'order' => 'That.field DESC',
'exclusive' => false, 'limit' => '5',
'finderQuery' => 'FULL JOIN QUERY' 'fields' => 'That.fields',
) 'offset' => 0,
); 'finderQuery' => 'FULL JOIN QUERY',
'deleteQuery' => 'FULL DELETE QUERY',
'insertQuery' => 'FULL INSERT QUERY'
)
);
Bryan English
cakephp.org - pivotlabs.com – cheatsheetheap.com
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License