Doctrine 数据固定问题
在哪里可以了解更多关于在yaml和数据装置中创建数据库标记的知识 我遵循了一个教程,他们创建了一个这样的关系:在用户和汽车的关系下。我的问题是为什么车里有“类型:多”。我可以把它放在用户端吗(只是好奇) abt数据类型。不同的数据库有不同的数据库支持。我认为在MySQL(这里使用的是InnoDB)中,整数应该是tinyint(x)、bigint(x)、int(x)。。。或者字符串应该是varchar而不是string?我在这里用的不是很严格吗Doctrine 数据固定问题,doctrine,yaml,Doctrine,Yaml,在哪里可以了解更多关于在yaml和数据装置中创建数据库标记的知识 我遵循了一个教程,他们创建了一个这样的关系:在用户和汽车的关系下。我的问题是为什么车里有“类型:多”。我可以把它放在用户端吗(只是好奇) abt数据类型。不同的数据库有不同的数据库支持。我认为在MySQL(这里使用的是InnoDB)中,整数应该是tinyint(x)、bigint(x)、int(x)。。。或者字符串应该是varchar而不是string?我在这里用的不是很严格吗 options: type: INNODB
options:
type: INNODB
collate: utf8_general_ci
charset: utf8
User:
columns:
id:
type: integer
primary: true
autoincrement: true
name: string(300)
email: string(300)
phone: string(9)
car_id: integer
relations:
Car:
local: car_id
foreign: id
Car:
columns:
id:
type: integer
primary: true
autoincrement: true
brand: string(300)
relations:
Users:
class: User
foreign: car_id
local: id
type: many
更新1
User:
columns:
username:
type: string(255)
password:
type: string(255)
contact_id:
type: integer
relations:
Contact:
class: Contact // if the table is named Contact, class will be Contact also?
local: contact_id
foreign: id
foreignAlias: User // whats alias for?
foreignType: one // one contact ... to ...
type: one // one user?
Contact:
columns:
first_name:
type: string(255)
last_name:
type: string(255)
phone:
type: string(255)
email:
type: string(255)
address:
type: string(255)
relations:
User:
class: User
local: id
foreign: contact_id
foreignAlias: Contact
foreignType: one
type: one
关于这个问题,以下是什么意思
attributes:
export: all
validate: true
tableName: group_table
refClass: GroupUser
在哪里可以了解更多关于在yaml和数据装置中创建数据库标记的知识
条令手册和章节
我可以把它放在用户端吗(只是好奇)
是的,但是这一部分将被称为foreignType
。这里有一个例子:
User:
columns:
id:
type: integer
primary: true
autoincrement: true
name: string(300)
email: string(300)
phone: string(9)
car_id: integer
relations:
Car:
local: car_id
foreign: id
foreignType: many
abt数据类型
好吧,条令列类型和数据库列类型“略有”不同。只是比较一下,比如说
在哪里可以了解更多关于在yaml和数据装置中创建数据库标记的知识
条令手册和章节
我可以把它放在用户端吗(只是好奇)
是的,但是这一部分将被称为foreignType
。这里有一个例子:
User:
columns:
id:
type: integer
primary: true
autoincrement: true
name: string(300)
email: string(300)
phone: string(9)
car_id: integer
relations:
Car:
local: car_id
foreign: id
foreignType: many
abt数据类型
好吧,条令列类型和数据库列类型“略有”不同。只是比较一下,比如说,。我知道这很古老,但我发现这些东西让人困惑,现在仍然如此。事实上,我不是所有可能性的专家,这只是基于对我有用的东西。我认为您可能在寻找多对多关系,但我完全避免了对它们的理论支持,而是明确定义了自己的关联表,因此我只使用一对多和一对一关系 如UPDATE1中所述,您仅在具有外键的一端指定关系
如果将类型指定为“many”,我实际上不知道会发生什么。实现这一点需要一个额外的关联表,就像多对多关系一样,我不知道信条是否会像多对多关系那样“自动”创建这样一个表。在我使用原则时,我尽量避免使用基于命名约定的隐式机器,因为我不太了解这些命名约定,所以我关闭了“检测关系”并避免使用多对多关系。我知道这很古老,但这些都是我发现令人困惑的事情,现在仍然如此。事实上,我不是所有可能性的专家,这只是基于对我有用的东西。我认为您可能在寻找多对多关系,但我完全避免了对它们的理论支持,而是明确定义了自己的关联表,因此我只使用一对多和一对一关系 如UPDATE1中所述,您仅在具有外键的一端指定关系