Mysql Symfony2+;学说选择关系形式
我有两个表,Mysql Symfony2+;学说选择关系形式,mysql,symfony,collections,doctrine,relationship,Mysql,Symfony,Collections,Doctrine,Relationship,我有两个表,clients和servicicios它们之间有关系,我只想返回客户的服务,而不是使用addAction表单时存在的所有服务,例如: `Client: Foo Services: Bar Bar2 Bar3 Client: Foo2 Services: Bar2 Bar7 Client: Foo3 Services: Bar` 我不知道如何
clients
和servicicios
它们之间有关系,我只想返回客户的服务,而不是使用addAction表单时存在的所有服务,例如:
`Client: Foo
Services:
Bar
Bar2
Bar3
Client: Foo2
Services:
Bar2
Bar7
Client: Foo3
Services:
Bar`
我不知道如何告诉Symfony2或条令,client Foo
分配了X个服务
这是yml
Pge\IncidenciasBundle\Entity\Clientes:
type: entity
table: clientes
id:
id:
type: integer
unsigned: false
nullable: false
generator:
strategy: IDENTITY
fields:
nombre:
type: string
length: 250
fixed: false
nullable: true
manyToOne:
servicio:
targetEntity: Servicios
cascade: { }
mappedBy: null
inversedBy: cliente
joinColumns:
servicio_id:
referencedColumnName: id
orphanRemoval: false
oneToMany:
incidencia:
targetEntity: Incidencias
cascade: { }
mappedBy: cliente
inversedBy: null
orphanRemoval: false
lifecycleCallbacks: { }
Pge\IncidenciasBundle\Entity\Servicios:
type: entity
table: servicios
id:
id:
type: integer
unsigned: false
nullable: false
generator:
strategy: IDENTITY
fields:
nombre:
type: string
length: 250
fixed: false
nullable: true
oneToMany:
cliente:
targetEntity: Clientes
cascade: { }
mappedBy: servicio
inversedBy: null
orphanRemoval: false
incidencia:
targetEntity: Incidencias
cascade: { }
mappedBy: servicio
inversedBy: null
orphanRemoval: false
lifecycleCallbacks: { }
条令无法确定哪个列应该是您的主键 将您的id在yaml文件中上移一级:
table: servicios
id:
id:
type: integer
unsigned: false
nullable: false
generator:
strategy: IDENTITY
fields:
然后运行app/console命令:schema:create--dumpsql
看看你能得到什么。可能还有其他错误。我看起来不太近。如有必要,从精简的yaml文件开始,然后一次添加一个字段。我想你也希望unsigned是真的。是的,谢谢。但问题是,我只想返回
客户端
及其服务,而不是使用addAction
表单时存在的所有服务,我不知道我是否解释得很好……不知道你在说什么。这个问题并没有提到任何形式行动。我认为这是一个“如何定义关系”类型的问题。希望其他人能帮忙;I don’我不会采取错误的方式,但通常认为1-发布问题,2-收到问题的有效答案,3-将问题改为完全不同的内容是一个坏主意。阅读问题,看到什么看起来像有效的yaml,然后看到回答说yaml是错误的,这会让人非常困惑。我想我可以删除我的答案,但那不是我的工作。