【发布时间】:2023-03-29 15:37:02
【问题描述】:
我对 CakePHP 如何处理它的数据库关系有点困惑。
对于一个hasOne关系,根据documentation:
“用户拥有一个个人资料”
User hasOne Profile -> profiles.user_id
Array
(
[User] => Array
(
[id] => 121
[name] => Gwoo the Kungwoo
[created] => 2007-05-01 10:31:01
)
[Profile] => Array
(
[id] => 12
[user_id] => 121
[skill] => Baking Cakes
[created] => 2007-05-01 10:31:01
)
)
但这不是一对多的关系吗?
例如(我做了这些表格来说明我的困惑):
在这种情况下,有 2 个配置文件属于同一用户。这不是意味着用户拥有许多个人资料吗?
如果“User hasOne Profile”是更有意义的
那么这将是“User hasOne Profile”但“Profile hasMany User”?
我不确定我是否理解正确。
【问题讨论】:
-
你从哪里得到这些表格图像?
-
我自己做的,只是为了说明我的困惑。
标签: php cakephp database-relations