I have HABTM and hasMany in one model like below:
var $hasMany = array(
'Interestsub' => array(
'className' => 'Interestsub',
'foreignKey' => 'interest_id',
'dependant' => true
)
);
var $hasAndBelongsToMany = array(
'User' => array(
'className' => 'User',
'joinTable' => 'interests_users',
'foreignKey' => 'interest_id',
'associationForeignKey' => 'user_id',
'unique' => true,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
)
);
The problem is when I do a find query with recursive 3 in User model it only gives me Interest and Interest_User model data but not Interestsub which is hasMany table.
Is there a way to get this with my find query so it is nested inside Interest?
Try recursive 2, or better yet, the containable behavior.
http://book.cakephp.org/2.0/en/core-libraries/behaviors/containable.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.