Bonjour,

A l'aide du schéma suivant :

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
Offre:
  actAs:
    Sluggable:
      fields:       [intitule]
      unique:       true
  tableName:        gbot_offre
  columns:
    id:
      type:         integer
      primary:      true
    file:
      type:         string(255)
      notnull:      true
    contact_id:
      type:         integer
    intitule:
      type:         string(255)
      notnull:      true
    organisme_id:
      type:         integer
      notnull:      true
    modalite_enseignement_id:
      type:         integer
    objectif_general_id:
      type:         integer
    nombre_heures_total:
      type:         integer
      notnull:      true
    niveau_entree_id:
      type:         integer
    conventionnement:
      type:         boolean
    prise_en_charge_frais:
      type:         boolean
    certifiante:
      type:         boolean
    info_derniere_minute:
      type:         string(4000)
    objectif_detaille:
      type:         string(3000)
      notnull:      true
    contenu:
      type:         string(3000)
      notnull:      true
    public_vise_id:
      type:         integer
    conditions_prise_en_charge:
      type:         string(3000)
      notnull:      true
  relations:
    Organisme:
      onDelete:     CASCADE
      alias:        organisme
      foreignAlias: offres
    ModaliteEnseignement:
      onDelete:     SET NULL
      alias:        modalite_enseignement
      foreignAlias: offres
    ObjectifGeneral:
      onDelete:     SET NULL
      alias:        objectif_general
      foreignAlias: offres
    NiveauDiplome:
      local:        niveau_entree_id
      onDelete:     SET NULL
      alias:        niveau_entree
      foreignAlias: offres
    Contact:
      onDelete:     SET NULL
      alias:        contact
      foreignAlias: offres
    PublicVise:
      onDelete:     SET NULL
      alias:        public_vise
      foreignAlias: offres
 
Session:
  tableName:        gbot_session
  columns:
    id:
      type:         integer
      primary:      true
    offre_id:
      type:         integer
      notnull:      true
    debut:
      type:         datetime
    fin:
      type:         datetime
    lieu_formation_id:
      type:         integer
      notnull:      true
  relations:
    Offre:
      onDelete:     CASCADE
      foreignAlias: sessions
    LieuFormation:
      alias:        lieu_formation
      onDelete:     CASCADE
      foreignAlias: sessions
 
LieuFormation:
  tableName:        gbot_lieu_formation
  columns:
    nom:
      type:         string(100)
      notnull:      true
    adresse:
      type:         string(300)
      notnull:      true
    commune_id:
      type:         integer
      notnull:      true
    accesHandicap:
      type:         string(300)
  relations:
    Commune:
      onDelete:     CASCADE
      foreign:      code_insee
      alias:        commune
      foreignAlias: lieuxformation
 
Commune:
  tableName:        gbot_commune
  actAs:
    Geographical:   ~
    Sluggable:
      fields:       [nom]
      unique:       true
  columns:
    code_insee:
      type:         integer
      primary:      true
    nom:
      type:         string(50)
      notnull:      true
    code_postal:
      type:         string(5)
      notnull:      true
    zone_emploi_id:
      type:         integer
    departement_id:
      type:         integer
  relations:
    Departement:
      onDelete:     SET NULL
      foreignAlias: communes
    ZoneEmploi:
      onDelete:     SET NULL
      foreignAlias: communes
je voudrais écrire une requête de ce genre là :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
Select offre.id, commune.nom
 from offre
Inner join session on session.offre_id=offre.id
Inner join lieuformation on lieuformation.id=session.lieu_formation_id
Inner join commune on commune.codeInsee=lieuFormation.commune_id
J'ai donc écrit :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
$q = $this->getOffresQuery()
                ->innerJoin('g.sessions s ON s.offre_id = g.id')
                ->innerJoin('s.lieu_formation l ON l.id = s.lieu_formation_id')
                ->innerJoin('l.commune k ON l.commune_id = k.code_insee')
                ->where('g.nombre_heures_total BETWEEN ? AND ?',array($criteres['dureeMin'],$criteres['dureeMax']))
                ->andWhereIn('k.zone_emploi_id',$criteres['zone'])
                ->orderBy('g.conventionnement DESC, g.intitule ASC');
Donc c'est la partie des innerJoin qui m'intéresse, car quand je lance le programme, cela m'indique
Unknown relation alias lieu_formation
J'avoue être un peu perdu là, et si quelqu'un peut m'aider je lui serai reconnaissant...

Merci d'avance