开发者

CakePHP - HABTM separate join table that also needs a HTBTM relationship

开发者 https://www.devze.com 2023-01-28 12:39 出处:网络
Im creating a HTBTM relation like: Dressess id name Dressess_Styles 开发者_JAVA百科 id dress_id style_id

Im creating a HTBTM relation like:


Dressess


id

name


Dressess_Styles


开发者_JAVA百科

id

dress_id

style_id


Styles


id

name


Now i need the every Dresses_Styles also can Has and Belongs to Many Colors.

My question:

Some light and considerations on how do I create this relationships without breaking CakePHP standard.

Please tell me what you think about this:


Colors_Dressess_Styles


id

dress_style_id

color_id


Colors


id

name

It is the correct way or exist a better one?

Thanks.


Looks good to me.

Dresses belongs to Dresses_Styles

Styles belongs to Dresses_Styles

Dresses_Styles HABTM Colors


It's just my rule of thumb, but when I need to to actually create HABTM model (to add methods, relationships, etc.), it usually means that it is a separate model by itself. Does Dresses_Styles represent any entity here?

0

精彩评论

暂无评论...
验证码 换一张
取 消