Symfony1 在理论中,如果两个关系是为同一个表中的两个独立列定义的,“关系”有什么含义?
假设我定义了VendorClientLicense模型,如下所示:Symfony1 在理论中,如果两个关系是为同一个表中的两个独立列定义的,“关系”有什么含义?,symfony1,doctrine,Symfony1,Doctrine,假设我定义了VendorClientLicense模型,如下所示: VendorClientLicense: tableName: vendor_client_licenses columns: id: type: integer(4) primary: true notnull: true autoincrement: true status: type: string(255) default:
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中发现,在生成的数据库中,客户机id不显示与sfGuardUser的任何关联,而供应商id显示!如果我将其更改为'sfGuardUser1'和'sfGuardUser2',则显示这两种关系!因此,我假设这最终具有重要意义,对于同一个模型不应该完全相同。是否还有其他影响
另外,你能给我命名一个好的模式生成器,比如“mysqlworkbenchdoctrineplugin”,它可以自动处理这种情况吗?是的,你需要用不同的名称来命名它们 我在这里询问并收到了相同的问题: 我没有任何问题
关于插件,很抱歉无法帮助您。谢谢您的回答。在浏览了你的链接之后,我想到了另一个问题。在这种情况下,“foreignAlias”的定义也需要不同。想想如果我使用这样的别名:“$user->getVendorClientLicenses”,它将如何决定选择哪个列作为引用客户机id或供应商id@梅德哈德:没错。。。您可以根据需要如何引用两端的关系来定义它们。