我的崗位模型的schema.yml(Symfony的1.4)學說/ MySQL的關係是這樣的:與多列PK臺
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 }
,你可以看到張貼有一個多列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
我如何處理這種關係?
我不熟悉這種表示法,但您需要一對多的表示法。另外postcomment應該有它的ID我猜! – GorillaApe