Salut a tous,

J'ai un souci de requete avec Doctrine.

Voici les tables du fichier YAML :

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
 
Site:
  connection: doctrine
  tableName: site
  columns:
    idsite:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    st_nom:
      type: string(45)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    st_mode_acces_reseau:
      type: string(45)
      fixed: false
      unsigned: false
      primary: false
      notnull: false
      autoincrement: false
    st_addresse:
      type: string(45)
      fixed: false
      unsigned: false
      primary: false
      notnull: false
      autoincrement: false
    st_commentaire:
      type: string(45)
      fixed: false
      unsigned: false
      primary: false
      notnull: false
      autoincrement: false
    entreprise_identreprise:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
 
Batiment:
  connection: doctrine
  tableName: batiment
  columns:
    idbatiment:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    bat_nom:
      type: string(45)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    bat_etage:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: false
      autoincrement: false
    bat_commentaire:
      type: string(45)
      fixed: false
      unsigned: false
      primary: false
      notnull: false
      autoincrement: false
    site_idsite:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
  relations:
    Service:
      foreignAlias: Batiments
      class: Service
      refClass: BatimentHasService # Many To Many
      local:  batiment_idbatiment
      foreign: service_idservice
 
Service:
  connection: doctrine
  tableName: service
  columns:
    idservice:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    svc_nom:
      type: string(45)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    svc_commentaire:
      type: string(45)
      fixed: false
      unsigned: false
      primary: false
      notnull: false
      autoincrement: false
  relations:
    Batiment:
      foreignAlias: Services
      class: Batiment
      refClass: BatimentHasService # Many To Many
      local:  service_idservice
      foreign:  batiment_idbatiment
    Personnel:
      foreignAlias: Services
      class: Personnel
      refClass: PersonnelHasService # Many To Many
 
 
BatimentHasService:
  connection: doctrine
  tableName: batiment_has_service
  columns:
    batiment_idbatiment:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: false
    service_idservice:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: false
  relations:
    Batiment:
      local: batiment_idbatiment
      foreign: idbatiment
      foreignAlias: BatimentHasServices
    Service:
      local: service_idservice
      foreign: idservice
      foreignAlias: BatimentHasServices
Pour récapituler :
- Un site a plusieurs batiments ( mais un batiment n'appartient qu'a un site ) : One To Many
- Un batiment peut contenir plusieurs service et reciproquement ( many to many )

Je voudrais la liste des Service d'un site X.

Ca devrait ressembler a un truc du genre si je me plante pas ( suis pas bon en sql ):

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
SELECT * 
FROM Service svc , Batiment b , BatimentHasService lien , Site s 
WHERE  b.site_idsite = X
AND svc.idservice = lien.service_idservice 
AND b.idbatiment = lien.batiment_idbatiment
Et je suis infoutu de l'ecrire en DQL , et le plus pénible c'est que la moindre erreur dans mon action plante tout et y'a pas trop moyen de debugger.

Si quelqu'un connait le moyen de faire ca en DQL

Merci d'avance