我是Symfony的新手,嘗試通過構建模型然後構建sql來創建數據庫結構。在Symfony中使用YAML創建的關係(與Doctrine)沒有在MySQL數據庫中填充
所有的表都出現在數據庫中,但是不會創建簡單的一對多關係以外的關係。
例如我有一個存儲公司的表,他們既可以是供應商也可以是客戶,我有另一個存儲客戶/供應商關係的表。
Identifier:
actAs: [Timestampable]
tableName: identifier
columns:
id:
type: integer(20)
fixed: false
unsigned: false
primary: true
autoincrement: true
relations:
Suppliers:
class: Identifier
local: customer_id
foreign: supplier_id
refClass: CustomerSupplier
foreignAlias: Customers
onDelete: CASCADE
Customers:
class: Identifier
local: supplier_id
foreign: customer_id
refClass: CustomerSupplier
foreignAlias: Suppliers
onDelete: CASCADE
CustomerSupplier:
actAs: [Timestampable]
tableName: customerSupplier
columns:
id:
type: integer(20)
fixed: false
unsigned: false
primary: true
autoincrement: true
customer_id:
type: integer(20)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
supplier_id:
type: integer(20)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
一比一的關係,不會創建或者:
IdentifierExtCompany:
actAs: [Timestampable]
tableName: identifierExtCompany
columns:
identifier_id:
type: integer(20)
fixed: false
unsigned: false
primary: true
autoincrement: true
relations:
Identifier:
local: identifier_id
foreign: id
onDelete: CASCADE
foreignType: one
type: one
所有這些關係不會當我運行通過構建-SQL生成的SQL請求出現在數據庫中。
你能幫我檢測我的yaml文件有什麼問題嗎?在此先感謝
您使用的是MyISAM嗎?你究竟在MySQL中稱之爲「關係」?外鍵? N:M表? – greg0ire 2011-03-17 09:16:36