开发者

Tables relationship in Cakephp

I am new to Models structure in Cakephp.

A few weeks ago I came across a tutorial in which the author

got three tables in Database:

Table A: {ID, Description, IsActive}
Table B: {ID, TableA_ID, Description, CreationDate, ModifiedDate}
Table A_B: {ID, TableA_ID, TableB_ID}

The author of the tutorial said that the third table (Tab开发者_如何转开发le A_B) is needed to

run in CakePHP.

I don't understand.

Is there any specific documentation in CakePHP that I can refer to?

I know there is a CookBook in Cakephp web site, but I couldn't find the

relevant infromation.


"... the third table (Table A_B) is needed to run in CakePHP."

Table B already includes a foreign key TableA_id referencing table A, implying a belongsTo or "one-to-many" relationship. Table A_B implies a hasAndBelongsToMany or "many-to-many" relationship. It seems a bit nonsensical to have both. You would need a really specific reason for this. Unless the author mentions this reason, disregard his advice. :)


I guess what you need is HABTM in the cookbook.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜