CakePHP defining additional fields in HABTM/ManyToMany relationship?

◇◆丶佛笑我妖孽 提交于 2019-12-06 12:33:56

if you want to have additional data in HABTM, use 2 hasMany relationships instead. So if A HABTM B, then set it up as: A hasMany A_B, B hasMany A_B, A_B belongsTo A, A_B belongsTo B. AFAIK, Cake support for HABTM is not very flexible.

class Person extends AppModel {
    ...
    $hasAndBelongsToMany = array('Company', array('with' => 'CompanyPerson'));
    ....
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!