开发者

CakePHP: Cake Bake HasOne association

开发者 https://www.devze.com 2023-03-22 07:56 出处:网络
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 present

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

精彩评论

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