Bonjour tout le monde,

J'ai un problème avec les embedRelations.
En effet j'ai une table "client", liée à une table "simulation" elle même liée à une autre table "relevé".
Elles sont en one-to-one. Jusque là pas de problème.
Je souhaite tout crée en un formulaire.
J'ai donc créé un ClientCustomForm dans lequel j'ai la simulation en embedRelation.
Dans cette même simulation j'ai ausi un embedRelation sur le relevé.

Lorsque je crée un enregistrement, doctrine crée deux enregistrements.
Le premier foireux, le second est valide.

Je me suis rendu compte que symfony faisait plusieurs Insert dans ses requêtes.
J'ai en plus dans la table client un lien vers un conseiller. J'ai donc dans mon formulaire un select avec la liste des conseillers.
La requête se permet de recréer un conseiller.
Je ne comprends pas du tout ce qui se passe.

Voici le log des requêtes :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
44	 Doctrine_Connection_Statement	execute : SELECT COUNT(*) AS num_results FROM advisor a WHERE a.id = ? - (3)
45	 Doctrine_Connection_Statement	execute : INSERT INTO tax_credit (type) VALUES (?) - ()
46	 Doctrine_Connection_Statement	execute : INSERT INTO financial (professional_situation, financial_type) VALUES (?, ?) - (Salaires, Auto-financement)
47	 Doctrine_Connection_Statement	execute : INSERT INTO consumption_statement (refrigerator, freezer, fridge_freezer, oven, dishwasher, hotplates, induction_hobs, coffee_maker, toaster, microwave_oven, household_appliances, kitchen_lightning, hifi_system, tv_dvd_recorder, aquarium, lounge_lightning, desktop_computer, laptop, printer, phone, router, circulation_pump, suppressor_robot, waterpool_garden_lightning, waterpool_heating, washing_machine, tumble_dryer, vacuum_cleaner, iron, vmc, radio, towel_dryer, extra_heating, electric_tooth_brush, bathroom_lightning, bedside_lamp, alarm_clock, room_lightning, room_tv, game_console, other_lightning, other_lightning2, garage_door, drill, jigsaw, lawnmower, carsher, double_glazing_windows, double_wall, south_verenda, isolated_attic, two_way_ventilation, chimney_trapdoor, heating_comment, water_production_comment, electricity_file, gaz_file, water_file, power_file, town_file, electric_rates_file, ejp_prices_file, files_comment) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) - (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, , , , , , , , , , )
48	 Doctrine_Connection_Statement	execute : INSERT INTO simulation (status_id, consumption_statement_id, created_at) VALUES (?, ?, ?) - (1, 11, 17-01-2011)
49	 Doctrine_Connection_Statement	execute : INSERT INTO advisor (company_id) VALUES (?) - ()
50	 Doctrine_Connection_Statement	execute : INSERT INTO client (marital_status, simulation_id, advisor_id) VALUES (?, ?, ?) - (Célibataire, 18, 15)
51	 Doctrine_Connection_Statement	execute : INSERT INTO simulation (status_id, consumption_statement_id, created_at) VALUES (?, ?, ?) - (1, 11, 17-01-2011)
52	 Doctrine_Connection_Statement	execute : INSERT INTO client (marital_status, taxcredit_id, financial_id, simulation_id, advisor_id, last_name, first_name, address_line1, address_line2, postal_code, city, phone_number, cellphone_number, fax_number, email) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) - (Célibataire, 11, 11, 19, 3, FFFFF, FFFFF, FFF, , FFFF, FFF, , , , fff@fff.fff)

Les trois insert en rouge n'ont rien à foutre là.

Mon formulaire client
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
 
//Schema ...
//Validators ...
 
$this->embedRelation('TaxCredit as taxCredit');
$this->embedRelation('Financial as financial');
$this->embedRelation('Simulation as simulation');
Simulation
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
 
//Schema ...
//Validators ...
 
$this->embedRelation('ConsumptionStatement as consumption');
Et enfin le schéma si ça vous parait pas clair
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
 
options:
  collate: utf8_general_ci
  charset: utf8
  type: InnoDB
 
 
Company:
    columns:
        number: { type: string(50), notnull: true, unique: true }
        name: { type: string(100), notnull: true }
        legal_form: { type: string(50), notnull: true }
        siret: { type: string(13), notnull: true }
        address_line1: { type: string(200), notnull: true }
        address_line2: { type: string(200) }
        postal_code: { type: string(200), notnull: true }
        city: { type: string(200), notnull: true }
    relations:
      Advisors:
        class: Advisor
        local: id
        foreign: company_id
        type: many
        foreignAlias: Company
 
 
Advisor:
    columns:
        sf_guard_user_id: { type: integer }
        parent_advisor_id: { type: integer }
        company_id: { type: integer }
        last_name: { type: string(100), notnull: true }
        first_name: { type: string(100), notnull: true }
        phone_number: { type: string(10) }
        email: { type: string(200) }
    relations:
        User:
            cascade: [delete]
            class: sfGuardUser
            local: sf_guard_user_id
            foreign: id
            foreignAlias: Advisor
            type: one
            foreignType: one
        Advisor:
            class: Advisor
            local: parent_advisor_id
            foreign: id
            foreignAlias: Children
        Company:
            class: Company
            local: company_id
            foreign: id
            foreignAlias: Advisors
            type: one
            cascade: [delete]
        Clients:
            class: Client
            local: id
            foreign: advisor_id
            foreignAlias: Advisor
            type: many
 
Client:
    columns:
        advisor_id: { type: integer }
        simulation_id: { type: integer }
        last_name: { type: string(100), notnull: true }
        first_name: { type: string(100), notnull: true }
        marital_status:
          type: enum
          values: ['Célibataire', 'Marié(e)', 'Divorcé(e)', 'Veuf(ve)']
          default: 'Célibataire'
        dependent_children: { type: integer, unsigned: true }
        address_line1: { type: string(200), notnull: true }
        address_line2: { type: string(200) }
        postal_code: { type: string(200), notnull: true }
        city: { type: string(200), notnull: true }
        phone_number: { type: string(10) }
        cellphone_number: { type: string(10) }
        fax_number: { type: string(10) }
        email: { type: string(200) }
        financial_id: { type: integer }
        taxcredit_id: { type: integer } 
    relations:
        Advisor:
            class: Advisor
            local: advisor_id
            foreign: id
            foreignAlias: Clients
            type: one
        Financial:
            class: Financial
            local: financial_id
            foreign: id
            foreignAlias: Client
            type: one
        TaxCredit:
            class: TaxCredit
            local: taxcredit_id
            foreign: id
            foreignAlias: Client
            type: one
        Simulation:
            class: Simulation
            local: simulation_id
            foreign: id
            foreignAlias: Client
            type: one
 
 
 
Simulation:
    actAs:
        Timestampable:
            created:
              format: d-m-Y
            updated:
                disabled: true
                name: last_update
                format: d-m-Y
    columns:
         status_id: { type: integer, default: 1 }
         consumption_statement_id: { type: integer }
         photovoltaic_id: { type: integer }
         thermodynamics_id: { type: integer }
         isolation_id: { type: integer }
    relations:
        Client:
            class: Client
            local: id
            foreign: simulation_id
            foreignAlias: Simulation
            type: one
        Status:
            class: SimulationStatus
            local: status_id
            foreign: id
            foreignAlias: Simulations
            type: one
        ConsumptionStatement:
            class: ConsumptionStatement
            local: consumption_statement_id
            foreign: id
            foreignAlias: Simulation
            type: one
        Photovoltaic:
            class: Photovoltaic
            local: photovoltaic_id
            foreign: id
            foreignAlias: Simulation
            type: one
        Thermodynamics:
            class: Thermodynamics
            local: thermodynamics_id
            foreign: id
            foreignAlias: Simulation
            type: one
        Isolation:
            class: Isolation
            local: isolation_id
            foreign: id
            foreignAlias: Simulation
            type: one
        Comments:
          class: Comment
          local: id
          foreign: simulation_id
          foreignAlias: Simulation
          type: many
 
SimulationStatus:
    columns:
        name: { type: string(200), notnull: true }
    relations:
        Simulations:
          class: Simulation
          local: id
          foreign: status_id
          foreignAlias: Status
          type: many
 
 
Photovoltaic:
    columns:
        board_type:
            type: enum
            values: ['Solar excellence', 'Syllia']
        board_model:
            type: enum
            values: ['SE 187-72', 'SE 214-96']
        count: { type: integer, unsigned: true }
        power: { type: integer, unsigned: true }
        price: { type: decimal, unsigned: true }
        calpinage: { type: string(100) }
        converter: { type: string(100) }
        roof_orientation: { type: decimal, unsigned: true }
        roof_gradient: { type: decimal, unsigned: true }
        height: { type: decimal, unsigned: true }
        length: { type: decimal, unsigned: true }
        pinion_height: { type: decimal, unsigned: true }
        sandquarry_height: { type: decimal, unsigned: true }
        crawling: { type: decimal, unsigned: true }
        cover_type:
            type: enum
            values: ['Ardoise', 'Cuivre', 'Fibro-ciment', 'Lauze', 'Taule Ondulée', 'Tuile Canal', 'Tuile Mécanique', 'Tuile Plate', 'Tuile Romaine', 'Zinc']
        framework_age: { type: integer, unsigned: true }
        lintels_area: { type: integer, unsigned: true }
        two_years: { type: boolean, default: false }
        dp1_cadastre: { type: string(200) }
        dp1_justif: { type: string(200) }
        dp5: { type: string(200) }
        dp7: { type: string(200) }
        dp8: { type: string(200) }
        erdf_box: { type: string(200) }
        edrf_link: { type: string(200) }
        erfd_link_type:
            type: enum
            values: ['Souterrain', 'Aérien', 'Aéro souterrain']
        erdf_zoom: { type: string(200) }
        erdf_table: { type: string(200) }
 
 
 
 
TechnicalProperty:
    columns:
      name: { type: string(200), notnull: true }
    relations:
      Photovoltaic:
        class: Photovoltaic
        refClass: SimulationTechnicalProperty
        foreignAlias: TechnicalProperties
        local: property_id
        foreign: photovoltaic_id
        type: many
 
 
Thermodynamics:
   columns:
     pipe_lenght_estimation: { type: decimal, scale: 2, unsigned: true }
     cumulus_watt_if_electric: { type: integer, unsigned: true }
     cumulus_water_capacity: { type: integer, unsigned: true }
     technical_room_file: { type: string(1024) }
     external_board_placement_file: { type: string(1024) }
     plumbing_map: { type: string(1024) }
   relations:
     Simulation:
       class: Simulation
       local: id
       foreign: thermodynamics_id
       foreignAlias: Thermodynamics
       type: one
 
 
Isolation:
  columns:
    dimension_estimation: { type: decimal, scale: 2, unsigned: true }
    volume_estimation: { type: decimal, scale: 2, unsigned: true }
    external_attic_view_file: { type: string(1024) }
    internal_attic_view_file: { type: string(1024) }
    attic_map: { type: string(1024) }
  relations:
    Simulation:
      class: Simulation
      local: id
      foreign: isolation_id
      foreignAlias: Isolation
      type: one
 
 
Financial:
    columns:
        professional_situation:
            type: enum
            values: ['Salaires', 'BIC', 'BNC']
        income: { type: decimal, unsigned: true }
        debt: { type: decimal, unsigned: true}
        financial_type:
           type: enum
           values: ['Auto-financement', 'Banque Client', 'Banque TerreAttitude']
    relations:
      Client:
        class: Client
        local: id
        foreign: financial_id
        foreignAlias: Financial
        type: one
 
 
TaxCredit:
    columns:
        type: { type: string(100) }
        date: { type: date }
        used: { type: decimal, unsigned: true }
    relations:
      Client:
        class: Client
        local: id
        foreign: taxcredit_id
        foreignAlias: TaxCredit
        type: one
 
Comment:
   actAs:
        Timestampable:
            created:
                name: created_at
                type: timestamp
                format: m-d-Y H
   columns:
        author_id: { type: integer }
        simulation_id: { type: integer }
        content: { type: string(1000) }
 
   relations:
        Simulation:
            class: Simulation
            local: simulation_id
            foreign: id
            foreignAlias: Comments
            type: one
 
 
SimulationTechnicalProperty:
    columns:
      photovoltaic_id: { type: integer, primary: true }
      property_id: { type: integer, primary: true }
      checked: { type: boolean, default: false }
      comment: { type: string(200) }
    relations:
      Photovoltaic:
        local: photovoltaic_id
        foreignAlias: SimulationTechnicalProperties
      TechnicalProperty:
        local: property_id
        foreignAlias: SimulationTechnicalProperties
 
 
 
ConsumptionStatement:
  columns:
    gaz_heating: { type: string(1024) }
    fuel_heating: { type: string(1024) }
    electric_heating: { type: string(1024) }
    wood_heating: { type: string(1024) }
    pac_heating: { type: string(1024) }
    heating_comment: { type: string(2000) }
    gaz_production: { type: string(1024) }
    boiler_production: { type: string(1024) }
    solar_production: { type: string(1024) }
    electric_production: { type: string(1024) }
    other_production: { type: string(1024) }
    water_production_comment: { type: string(2000) }
    refrigerator: { type: boolean, default: false }
    freezer: { type: boolean, default: false }
    fridge_freezer: { type: boolean, default: false }
    oven: { type: boolean, default: false }
    dishwasher: { type: boolean, default: false }
    hotplates: { type: boolean, default: false }
    induction_hobs: { type: boolean, default: false }
    coffee_maker: { type: boolean, default: false }
    toaster: { type: boolean, default: false }
    microwave_oven: { type: boolean, default: false }
    household_appliances: { type: boolean, default: false }
    kitchen_lightning: { type: boolean, default: false }
    hifi_system: { type: boolean, default: false }
    tv_dvd_recorder: { type: boolean, default: false }
    aquarium: { type: boolean, default: false }
    lounge_lightning: { type: boolean, default: false }
    desktop_computer: { type: boolean, default: false }
    laptop: { type: boolean, default: false }
    printer: { type: boolean, default: false }
    phone: { type: boolean, default: false }
    router: { type: boolean, default: false }
    circulation_pump: { type: boolean, default: false }
    suppressor_robot: { type: boolean, default: false }
    waterpool_garden_lightning: { type: boolean, default: false }
    waterpool_heating: { type: boolean, default: false }
    washing_machine: { type: boolean, default: false }
    tumble_dryer: { type: boolean, default: false }
    vacuum_cleaner: { type: boolean, default: false }
    iron: { type: boolean, default: false }
    vmc: { type: boolean, default: false }
    radio: { type: boolean, default: false }
    towel_dryer: { type: boolean, default: false }
    extra_heating: { type: boolean, default: false }
    electric_tooth_brush: { type: boolean, default: false }
    bathroom_lightning: { type: boolean, default: false }
    bedroom_number: { type: integer, unsigned: true }
    bedside_lamp: { type: boolean, default: false }
    alarm_clock: { type: boolean, default: false }
    room_lightning: { type: boolean, default: false }
    room_tv: { type: boolean, default: false }
    game_console: { type: boolean, default: false }
    other_lightning: { type: boolean, default: false }
    other_lightning2: { type: boolean, default: false }
    garage_door: { type: boolean, default: false }
    diy_tools_number: { type: integer, unsigned: true }
    drill: { type: boolean, default: false }
    jigsaw: { type: boolean, default: false }
    lawnmower: { type: boolean, default: false }
    carsher: { type: boolean, default: false }
    double_glazing_windows: { type: boolean, default: false }
    double_wall: { type: boolean, default: false }
    south_verenda: { type: boolean, default: false }
    isolated_attic: { type: boolean, default: false }
    two_way_ventilation: { type: boolean, default: false }
    chimney_trapdoor: { type: boolean, default: false }
    electricity_file: { type: string(1024) }
    gaz_file: { type: string(1024) }
    water_file: { type: string(1024) }
    power_file: { type: string(1024) }
    town_file: { type: string(1024) }
    electric_rates_file: { type: string(1024) }
    ejp_prices_file: { type: string(1024) }
    files_comment: { type: string(2000) }
  relations:
    Simulation:
      class: Simulation
      local: id
      foreign: consumption_statement_id
      foreignAlias: ConsumptionStatement
      type: one
Si quelqu'un a déja rencontré ce genre de problèmes. Merci de m'en faire part.