小编Ale*_*nko的帖子

Yii2迁移中的多对多关系

我有 2 张桌子,postcomment. 在 Laravel 中,我可以comment_post通过在模型中定义关系来隐式创建数据透视表。我如何在 Yii2 中做同样的事情?

桌柱:

  id    -- PK
  text
Run Code Online (Sandbox Code Playgroud)

表评论:

  id    -- PK
  text
  user_id
Run Code Online (Sandbox Code Playgroud)

表comment_post:

  id    -- PK
  post_id   -- foreign key references ID on post table
  comment_id    -- foreign key references ID on comment table
Run Code Online (Sandbox Code Playgroud)

migration many-to-many relation yii2

2
推荐指数
1
解决办法
1718
查看次数

标签 统计

many-to-many ×1

migration ×1

relation ×1

yii2 ×1