Bonjour,
J'ai 2 entités Departement et ChefDept qui sont liées en relation one to one unidirectionelle.
Un département à un seul chef et un chef n'est chef que d'un seul département.
Lorsque je tape dans la console php app/console doctrine:schema:create , j'ai l'exception suivante qui est levée :
Je mets le code des mes entités :
ChefDept.php
Departement.php
Merci d'avance pour votre aide
J'ai 2 entités Departement et ChefDept qui sont liées en relation one to one unidirectionelle.
Un département à un seul chef et un chef n'est chef que d'un seul département.
Lorsque je tape dans la console php app/console doctrine:schema:create , j'ai l'exception suivante qui est levée :
[Doctrine\ORM\ORMException] Column name `id` referenced for relation from MyQL\HMBundle\Entity\Departement towards MyQL\HMBundle\Entity\ChefDept does not exist.
Je mets le code des mes entités :
ChefDept.php
<?php namespace MyQL\HMBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * * @ORM\Entity * @ORM\Table(name="chefDept") */ class ChefDept { /** * * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue */ protected $idChef; /** * * @ORM\Column(type="string", length=30) */ protected $nomChef; /** * Get idChef * * @return integer */ public function getIdChef() { return $this->idChef; } /** * Set nomChef * * @param String $nomChef */ public function setNomChef(\String $nomChef) { $this->nomChef = $nomChef; } /** * Get nomChef * * @return String */ public function getNomChef() { return $this->nomChef; } }
Departement.php
<?php namespace MyQL\HMBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * * @ORM\Entity * @ORM\Table(name="Departement") */ class Departement { /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue */ protected $idDep; /** * * @ORM\Column(type="string", length=30) */ protected $nomDep; /** * @ORM\OneToOne(targetEntity="MyQL\HMBundle\Entity\chefDept", cascade={"persist"}) */ protected $chefDept; /** * Get idDep * * @return integer */ public function getIdDep() { return $this->idDep; } /** * Set nomDep * * @param String $nomDep */ public function setNomDep(\String $nomDep) { $this->nomDep = $nomDep; } /** * Get nomDep * * @return String */ public function getNomDep() { return $this->nomDep; } /** * Set chefDept * * @param MyQL\HMBundle\Entity\ChefDept $chefDept */ public function setChefDept(\MyQL\HMBundle\Entity\ChefDept $chefDept) { $this->chefDept = $chefDept; } /** * Get chefDept * * @return MyQL\HMBundle\Entity\ChefDept */ public function getChefDept() { return $this->chefDept; } }
Merci d'avance pour votre aide