2010-11-11 50 views
0

假设我已经定义VendorClientLicense模式是这样的:在学说中,'关系'具有什么含义:'如果两个关系是用同一个表定义的,那么这两个关系是如何定义的?

VendorClientLicense: 
    tableName: vendor_client_licenses 
    columns: 
    id: 
     type: integer(4) 
     primary: true 
     notnull: true 
     autoincrement: true 
    status: 
     type: string(255) 
     default: 'pending' 
    client_id: 
     type: integer(8) 
     notnull: true 
    vendor_id: 
     type: integer(8) 
     notnull: true 
    relations: 
    sfGuardUser: 
     class: sfGuardUser 
     local: client_id 
     foreign: id 
     foreignAlias: VendorClientLicenses 
     foreignType: many 
     owningSide: true 
    sfGuardUser: 
     class: sfGuardUser 
     local: vendor_id 
     foreign: id 
     foreignAlias: VendorClientLicenses 
     foreignType: many 
     owningSide: true 
    indexes: 
    fk_vendor_client_licenses_sf_guard_user1: 
     fields: [client_id] 
    fk_vendor_client_licenses_sf_guard_user2: 
     fields: [vendor_id] 
    options: 
    charset: utf8 
    collate: utf8_unicode_ci 

如果你看到两个关系具有相同名称的“sfGuarduser”定义;我在mysql中发现的是,在生成的数据库client_id没有显示任何关联sfGuardUser,而vendor_id呢!如果我将其更改为'sfGuardUser1'和'sfGuardUser2',则会显示两种关系!所以我认为这最终具有重要的意义,并且不应该是相同的模型。有没有其他的影响呢?

加上你能命名为一个像'mysqlworkbenchdoctrineplugin'这样自动处理情况的好架构生成器吗?

回答

0

是的,你需要以不同的方式命名它们。

我问收到此相同的问题&:

MySQL: Two foreign keys in one table referring to another table

我还没有与此有关的任何问题。

关于插件,抱歉不能帮你。

+0

感谢您的回答。在通过你的链接后,我的脑海里出现了另一个问题。在这种情况下,“外国舞蹈”也需要有不同的定义。想想如果我使用别名:'$ user-> getVendorClientLicenses()',它将如何决定选择哪个列作为参考(client_id或vendor_id)! – med 2010-11-13 11:34:52

+0

@medhad:完全......你可以根据你需要如何引用两端关系来定义它们。 – Tom 2010-11-13 17:40:21

相关问题