Reputation: 3003
I have two tables, Clientes
and Servicios
they have relationships, I want doctrine return the client with it's services only instead of all services that exists when I'm using the addAction form, for example:
`Client: Foo
Services:
Bar
Bar2
Bar3
Client: Foo2
Services:
Bar2
Bar7
Client: Foo3
Services:
Bar`
I don't know how to tell Symfony2 or Doctrine that client Foo
has X services assigned...
This is doctrine 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: { }
Upvotes: 0
Views: 96
Reputation: 48865
Doctrine cannot determine which column is supposed to be your primary key.
Move your id to up one level in your yaml files:
table: servicios
id:
id:
type: integer
unsigned: false
nullable: false
generator:
strategy: IDENTITY
fields:
Then run app/console doctrine:schema:create --dump-sql
And see what you get. There may be other errors. I didn't look real close. If necessary, start with a stripped down yaml file then add one field at a time. I suspect you want unsigned to be true as well.
Upvotes: 1