mysql 表字段 pk_Doctrine / MySql与多列PK表的关系
发布日期:2021-06-24 13:10:25 浏览次数:2 分类:技术文章

本文共 746 字,大约阅读时间需要 2 分钟。

schema.yml(Symfony 1.4)中的My Post模型看起来像这样:

Post:

columns:

id: { type: bigint, notnull: true, primary: true }

blog_id: { type: bigint, notnull: true, primary: true }

user_id: { type: bigint, notnull: true }

subject: { type: string(255), notnull: true }

short_body: { type: text, notnull: true }

long_body: { type: text }你可以看到Post有一个多列PK。我的问题是“我如何与这个模型创建n:1关系?”

作为一个例子,我想要这样的东西:

PostComment:

columns:

post_id: { type: bigint, notnull: true }

blog_id: { type: bigint, notnull: true }

name: { type: string(255), notnull: true }

email: { type: string(255) }

text: { type: text, notnull: true }

relations:

Post:

#Here is my problem. What should I write here?

local: ????

foreign: ????

foreignAlias: Comments

onDelete: cascade

onUpdate: cascade我如何处理这种关系?

转载地址:https://blog.csdn.net/weixin_33001305/article/details/114811472 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:java 怎样打印hex_java基础练习--打印 " * "及字母
下一篇:java过滤小写字母的正则_AJPFX总结关于Java中过滤出字母、数字和中文的正则表达式...

发表评论

最新留言

关注你微信了!
[***.104.42.241]2024年04月11日 03时50分00秒