开发者

CakePHP: Cake Bake HasOne association

I use the following db setup:

users:

  • id
  • name
  • country_id (FK)

countries

  • id
  • name

I use this setup for data integrity. W开发者_如何学运维hen a user adds an account, a country dropdown is presented in the add form through a find(list).

The problem is that while Cake Baking, I can not choose a HasOne relationship between users and countries. I can only choose that a User BelongsTo a country.

What goes wrong here? Do I need to add the HasOne association manually or is the BelongsTo relationship correct?

Thanks


I assume you mean hasMany, as in a country has many users. Yes, you'll have to define that in Country model, if you wish to have that relationship.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜