Tuesday, 15 April 2014

php - How to save in a table on a many to many relationship with attributes in this relationship -



php - How to save in a table on a many to many relationship with attributes in this relationship -

hello, new in symfony2, trying maintain in generated table of many many relationship attributes of relationship. problem persists. have spent more 2 days trying works, , clear cannot create alone, go lastly opportunity. have entity called ordenproduccion , other called empleado, these 2 entities related of many many , relationship generates table, relationship have attributes. entities next ones.

class empleado { /** * @var integer $id * * @orm\column(name="id", type="integer", length=3, nullable=false) * @orm\id */ private $id; /** * @var string $nombre * * @orm\column(name="nombre", type="string", length=255, nullable=false) */ private $nombre; /** * @orm\onetomany(targetentity="empleadooproduccion" , mappedby="empleado") */ private $orden;

i made entity represented table of relationship in bd

class empleadooproduccion { /** * @orm\id * @orm\manytoone(targetentity="empleado", inversedby="id") * @orm\joincolumn(name="empleado_id", referencedcolumnname="id") */ private $empleado; /** * @orm\id * @orm\manytoone(targetentity="ordenproduccion", inversedby="id") * @orm\joincolumn(name="orden_id", referencedcolumnname="id") */ private $orden; /** * @var \time $tiempo * * @orm\column(name="tiempo", type="time", nullable=false) */ private $tiempo; /** * @var float $salarioporhora * * @orm\column(name="salarioporhora", type="float") */ private $salarioporhora;

and other entity

class ordenproduccion { /** * @var integer $id * * @orm\column(name="id", type="integer", nullable=false) * @orm\id * @orm\generatedvalue(strategy="identity") */ private $id; /** * @var string $noorden * * @orm\column(name="no_orden", type="string", length=5, nullable=false) */ private $noorden; /** * @orm\onetomany(targetentity="empleadooproduccion", mappedby="orden") */ private $empleados;

i want 1 time insert ordenproduccion can associate many employees exist in bd.

please help me...

you don't have many-to-many-relationship in entities. good, because attributes on relationship have 2 separate relationships intermediate entity.

what not work? helpful, when provide english language names entities , attributes.

and somehow annotations don't create much sense. instance:

/** * @orm\id * @orm\manytoone(targetentity="empleado", inversedby="id") * @orm\joincolumn(name="empleado_id", referencedcolumnname="id") */ private $empleado;

inversedby="id" can't right - although may unrelated problem.

in order describe designed entities not match expectations, need see code works entities - , fails.

php symfony2 many-to-many

No comments:

Post a Comment