Ver Mensaje Individual
  #2 (permalink)  
Antiguo 01/03/2016, 06:41
Avatar de cluster28
cluster28
 
Fecha de Ingreso: enero-2008
Ubicación: Donostia - San Sebastián
Mensajes: 756
Antigüedad: 16 años, 4 meses
Puntos: 32
Respuesta: Relación OneToMany

Prueba así. Más o menos. No lo he probado.

Aquí tienes más ayuda: http://doctrine-orm.readthedocs.org/...n-mapping.html

Código PHP:
Ver original
  1. <?php
  2.  
  3. namespace VnfqInstComBundleEntity;
  4.  
  5. use DoctrineORMMapping as ORM;
  6. use DoctrineCommonCollectionsArrayCollection;
  7.  
  8. /**
  9.  * InstCom
  10.  *
  11.  * @ORM\Table(name="installation_companies")
  12.  * @ORM\Entity(repositoryClass="Vnfq\InstComBundle\Repository\InstComRepository")
  13.  */
  14. class InstCom
  15. {
  16.     /**
  17.      * @ORM\OneToMany(targetEntity="District", mappedBy="instcom")
  18.      */
  19.     protected $districts;
  20.    
  21.     /**
  22.      * @ORM\OneToMany(targetEntity="State", mappedBy="instcom")
  23.      */
  24.     protected $states;
  25.  
  26.     public function __construct()
  27.     {
  28.         $this->districts = new ArrayCollection();
  29.         $this->states = new ArrayCollection();
  30.     }

Código PHP:
Ver original
  1. <?php
  2.  
  3. namespace VnfqInstComBundleEntity;
  4.  
  5. use DoctrineORMMapping as ORM;
  6.  
  7. /**
  8.  * Disctrict
  9.  *
  10.  * @ORM\Table(name="disctricts_brasil")
  11.  * @ORM\Entity(repositoryClass="Vnfq\InstComBundle\Repository\DisctrictRepository")
  12.  */
  13. class Disctrict
  14. {
  15.     /**
  16.      * @ORM\ManyToOne(targetEntity="InstCom", inversedBy="districts")
  17.      * @ORM\JoinColumn(name="districts", referencedColumnName="id")
  18.      */
  19.     protected $instcom;

Código PHP:
Ver original
  1. <?php
  2.  
  3. namespace VnfqInstComBundleEntity;
  4.  
  5. use DoctrineORMMapping as ORM;
  6.  
  7. /**
  8.  * State
  9.  *
  10.  * @ORM\Table(name="states_brasil")
  11.  * @ORM\Entity(repositoryClass="Vnfq\InstComBundle\Repository\StateRepository")
  12.  */
  13. class State
  14. {
  15.     /**
  16.      * @ORM\ManyToOne(targetEntity="InstCom", inversedBy="states")
  17.      * @ORM\JoinColumn(name="states", referencedColumnName="id")
  18.      */
  19.     protected $instcom;