Bonjour,

Je souhaiterais faire l'équivalent de cette requête avec symfony2 seulement j'ai un soucis au niveau de

Code : Sélectionner tout - Visualiser dans une fenêtre à part
SELECT nom_option FROM fcpe.eleve_has_options a, fcpe.options b WHERE b.idoption = a.options_idoption AND a.eleve_ideleve = 5 ;
Seulement ça ne fonctionne pas j'ai des erreur. voici ma requete avec symfony
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
       $query2 = $this->getDoctrine()->getEntityManager()->createQuery("SELECT b.nomOption FROM LGBBourseLivresBundle:Options b, LGBBourseLivresBundle:Eleve a WHERE b.idoption = a.optionsoption");
        $eleve2 = $query2->getResult();
Voici mon entity Eleve ci dessous qui contient le champs options_idoption et eleve_ideleve
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<?php
 
namespace LGB\BourseLivresBundle\Entity;
 
use Doctrine\ORM\Mapping as ORM;
 
use Symfony\Component\Validator\Constraints as Assert;
 
/**
 * LGB\BourseLivresBundle\Entity\Eleve
 *
 * @ORM\Table(name="eleve")
 * @ORM\Entity(repositoryClass="LGB\BourseLivresBundle\Entity\EleveRepository")
 */
class Eleve
{
    /**
     * @var integer $ideleve
     *
     * @ORM\Column(name="ideleve", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $ideleve;
 
    /**
     * @var string $nom
     *
     * @ORM\Column(name="nom", type="string", length=30, nullable=false)
     */
    private $nom;
 
    /**
     * @var string $prenom
     * 
     * @ORM\Column(name="prenom", type="string", length=30, nullable=false)
     */
    private $prenom;
 
    /**
     * @var date $dateNaissance
     * 
     * @ORM\Column(name="date_naissance", type="date", nullable=false)
     */
    private $dateNaissance;
 
    /**
     * @var Options
     *
     * @ORM\ManyToMany(targetEntity="Options", inversedBy="eleveeleve")
     * @ORM\JoinTable(name="eleve_has_options",
     *   joinColumns={
     *     @ORM\JoinColumn(name="eleve_ideleve", referencedColumnName="ideleve")
     *   },
     *   inverseJoinColumns={
     *     @ORM\JoinColumn(name="options_idoption", referencedColumnName="idoption")
     *   }
     * )
     */
    private $optionsoption;
 
    /**
     * @var Classe
     *
     * @ORM\ManyToOne(targetEntity="Classe")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="classe_idclasse", referencedColumnName="idclasse")
     * })
     */
    private $classeclasse;
 
    /**
     * @var Parents
     *
     * @ORM\ManyToOne(targetEntity="Parents")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="parent_idparent", referencedColumnName="idparent")
     * })
     */
    private $parentparent;
 
    public function __construct()
    {
        $this->optionsoption = new \Doctrine\Common\Collections\ArrayCollection();
    }
 
 
    /**
     * Get ideleve
     *
     * @return integer 
     */
    public function getIdeleve()
    {
        return $this->ideleve;
    }
 
    /**
     * Set nom
     *
     * @param string $nom
     */
    public function setNom($nom)
    {
        $this->nom = $nom;
    }
 
    /**
     * Get nom
     *
     * @return string 
     */
    public function getNom()
    {
        return $this->nom;
    }
 
    /**
     * Set prenom
     *
     * @param string $prenom
     */
    public function setPrenom($prenom)
    {
        $this->prenom = $prenom;
    }
 
    /**
     * Get prenom
     *
     * @return string 
     */
    public function getPrenom()
    {
        return $this->prenom;
    }
 
    /**
     * Set dateNaissance
     *
     * @param date $dateNaissance
     */
    public function setDateNaissance($dateNaissance)
    {
        $this->dateNaissance = $dateNaissance;
    }
 
    /**
     * Get dateNaissance
     *
     * @return date 
     */
    public function getDateNaissance()
    {
        return $this->dateNaissance;
    }
 
    /**
     * Add optionsoption
     *
     * @param LGB\BourseLivresBundle\Entity\Options $optionsoption
     */
    public function addOptions(\LGB\BourseLivresBundle\Entity\Options $optionsoption)
    {
        $this->optionsoption[] = $optionsoption;
    }
 
    /**
     * Get optionsoption
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getOptionsoption()
    {
        return $this->optionsoption;
    }
 
    /**
     * Set classeclasse
     *
     * @param LGB\BourseLivresBundle\Entity\Classe $classeclasse
     */
    public function setClasseclasse(\LGB\BourseLivresBundle\Entity\Classe $classeclasse)
    {
        $this->classeclasse = $classeclasse;
    }
 
    /**
     * Get classeclasse
     *
     * @return LGB\BourseLivresBundle\Entity\Classe 
     */
    public function getClasseclasse()
    {
        return $this->classeclasse;
    }
 
    /**
     * Set parentparent
     *
     * @param LGB\BourseLivresBundle\Entity\Parents $parentparent
     */
    public function setParentparent(\LGB\BourseLivresBundle\Entity\Parents $parentparent)
    {
        $this->parentparent = $parentparent;
    }
 
    /**
     * Get parentparent
     *
     * @return LGB\BourseLivresBundle\Entity\Parents 
     */
    public function getParentparent()
    {
        return $this->parentparent;
    }
}
Merci