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 :[Doctrine\ORM\ORMException] Column name `id` referenced for relation from MyQL\HMBundle\Entity\Departement towards MyQL\HMBundle\Entity\ChefDept does not exist.
ChefDept.php
Departement.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 <?phpnamespace 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; } }
Merci d'avance pour votre aide
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81 <?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; } }
Partager