IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Symfony PHP Discussion :

Error SQL lors de l'enregistrement d'un champ de type Entity


Sujet :

Symfony PHP

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Octobre 2006
    Messages
    39
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2006
    Messages : 39
    Points : 25
    Points
    25
    Par défaut Error SQL lors de l'enregistrement d'un champ de type Entity
    Bonjour à tous,

    Je me prend la tête sur un soucis, si une âme charitable voulait bien m'aider svp ...

    J'ai 2 entités (Cycle et Car) avec une relation OneToMany. Je passe donc par un FormType pour pouvoir afficher les champs de ces 2 entity sur le même form.
    Dans l'entité "Car", j'ai un champ "avmake" (la marque de la voiture) qui est une valeur de l'entité "make", je passe donc par un champ de type entity pour qu'il m'affiche la liste des marques dans le formulaire.
    Le formulaire s'affiche correctement, j'ai bien tous les champs que je veux et j'ai aussi le Select avec toutes mes marques. Malheureusement, quand je submit le formulaire, j'ai l'erreur suivante qui apparait :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    An exception occurred while executing 'UPDATE Car SET avmake = ? WHERE id = ?' with params [{}, 1]:
     
    Catchable Fatal Error: Object of class Alcopa\Bundle\UnityBundle\Entity\Autovistamake could not be converted to string
    Le "1" dans les paramètres correspond à l'ID en base du Car. C'est l'ID du Select qui n'est pas remonté et je ne trouve pas pourquoi ...

    Voici mes différents fichiers

    Entity Car:
    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
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    <?php
     
    namespace Alcopa\Bundle\UnityBundle\Entity;
     
    use Doctrine\ORM\Mapping as ORM;
     
    /**
     * Car
     *
     * @ORM\Table()
     * @ORM\Entity(repositoryClass="Alcopa\Bundle\UnityBundle\Entity\CarRepository")
     */
    class Car
    {
        /**
    
         * @var integer
         *
         * @ORM\Column(name="id", type="integer")
         * @ORM\Id
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        private $id;
     
        /**
         * Get id
         *
         * @return integer
         */
        public function getId()
        {
            return $this->id;
        }
     
        /**
    
         * @var \DateTime
         *
         * @ORM\Column(name="created_at", type="datetime")
         */
        private $createdAt;
     
        /**
         * Set createdAt
         *
         * @param \DateTime $createdAt
         * @return Car
         */
        public function setCreatedAt($createdAt)
        {
            $this->createdAt = $createdAt;
     
            return $this;
        }
     
        /**
         * Get createdAt
         *
         * @return \DateTime
         */
        public function getCreatedAt()
        {
            return $this->createdAt;
        }
     
        /**
    
         * @var \DateTime
         *
         * @ORM\Column(name="updated_at", type="datetime")
         */
        private $updatedAt;
     
        /**
         * Set updatedAt
         *
         * @param \DateTime $updatedAt
         * @return Car
         */
        public function setUpdatedAt($updatedAt)
        {
            $this->updatedAt = $updatedAt;
     
            return $this;
        }
     
        /**
         * Get updatedAt
         *
         * @return \DateTime
         */
        public function getUpdatedAt()
        {
            return $this->updatedAt;
        }
     
        /**
    
         * @var string
         *
         * @ORM\Column(name="plate", type="string", length=16)
         */
        private $plate;
     
        /**
         * Set plate
         *
         * @param string $plate
         * @return Car
         */
        public function setPlate($plate)
        {
            $this->plate = $plate;
     
            return $this;
        }
     
        /**
         * Get plate
         *
         * @return string
         */
        public function getPlate()
        {
            return $this->plate;
        }
     
        /**
    
         * @var string
         *
         * @ORM\Column(name="serialnumber", type="string", length=20)
         */
        private $serialnumber;
     
        /**
         * Set serialnumber
         *
         * @param string $serialnumber
         * @return Car
         */
        public function setSerialnumber($serialnumber)
        {
            $this->serialnumber = $serialnumber;
     
            return $this;
        }
     
        /**
         * Get serialnumber
         *
         * @return string
         */
        public function getSerialnumber()
        {
            return $this->serialnumber;
        }
     
        /**
    
         * @var integer
         *
         * @ORM\Column(name="weight", type="integer")
         */
        private $weight;
     
        /**
         * Set weight
         *
         * @param integer $weight
         * @return Car
         */
        public function setWeight($weight)
        {
            $this->weight = $weight;
     
            return $this;
        }
     
        /**
         * Get weight
         *
         * @return integer
         */
        public function getWeight()
        {
            return $this->weight;
        }
     
        /**
    
         * @var integer
         *
         * @ORM\Column(name="length", type="integer")
         */
        private $length;
     
        /**
         * Set length
         *
         * @param integer $length
         * @return Car
         */
        public function setLength($length)
        {
            $this->length = $length;
     
            return $this;
        }
     
        /**
         * Get length
         *
         * @return integer
         */
        public function getLength()
        {
            return $this->length;
        }
     
        /**
    
         * @var integer
         *
         * @ORM\Column(name="height", type="integer")
         */
        private $height;
     
        /**
         * Set height
         *
         * @param integer $height
         * @return Car
         */
        public function setHeight($height)
        {
            $this->height = $height;
     
            return $this;
        }
     
        /**
         * Get height
         *
         * @return integer
         */
        public function getHeight()
        {
            return $this->height;
        }
     
        /**
    
         * @var integer
         *
         * @ORM\Column(name="depth", type="integer")
         */
        private $depth;
     
        /**
         * Set depth
         *
         * @param integer $depth
         * @return Car
         */
        public function setDepth($depth)
        {
            $this->depth = $depth;
     
            return $this;
        }
     
        /**
         * Get depth
         *
         * @return integer
         */
        public function getDepth()
        {
            return $this->depth;
        }
     
        /**
    
         * @var string
         *
         * @ORM\Column(name="avmake", type="string", length=255)
         */
        private $avmake;
     
        /**
         * Set avmake
         *
         * @param string $avmake
         * @return Car
         */
        public function setAvmake($avmake)
        {
            $this->avmake = $avmake;
     
            return $this;
        }
     
        /**
         * Get avmake
         *
         * @return string
         */
        public function getAvmake()
        {
            return $this->avmake;
        }
     
        /**
    
         * @var string
         *
         * @ORM\ManyToOne(targetEntity="Autovistamake")
         */
        private $autovistamake;
     
        /**
         * Set autovistamake
         *
         * @param \Alcopa\UnityBundle\Entity\Autovistamake $autovistamake
         * @return Car
         */
        public function setAutovistamake($autovistamake)
        {
            $this->autovistamake = $autovistamake;
     
            return $this;
        }
     
        /**
         * Get autovistamake
         *
         * @return Autovistamake
         */
        public function getAutovistamake()
        {
            return $this->autovistamake;
        }
     
        /**
    
         * @var string
         *
         * @ORM\Column(name="avmodel", type="string", length=255)
         */
        private $avmodel;
     
        /**
         * Set avmodel
         *
         * @param string $avmodel
         * @return Car
         */
        public function setAvmodel($avmodel)
        {
            $this->avmodel = $avmodel;
     
            return $this;
        }
     
        /**
         * Get avmodel
         *
         * @return string
         */
        public function getAvmodel()
        {
            return $this->avmodel;
        }
     
        /**
    
         * @var string
         *
         * @ORM\ManyToOne(targetEntity="Autovistamodel")
         */
        private $autovistamodel;
     
        /**
         * Set autovistamodel
         *
         * @param \Alcopa\UnityBundle\Entity\Autovistamodel $autovistamodel
         * @return Car
         */
        public function setAutovistamodel($autovistamodel)
        {
            $this->autovistamodel = $autovistamodel;
     
            return $this;
        }
     
        /**
         * Get autovistamodel
         *
         * @return Autovistamodel
         */
        public function getAutovistamodel()
        {
            return $this->autovistamodel;
        }
     
        /**
    
         * @var string
         *
         * @ORM\Column(name="avtype", type="string", length=255)
         */
        private $avtype;
     
        /**
         * Set avtype
         *
         * @param string $avtype
         * @return Car
         */
        public function setAvtype($avtype)
        {
            $this->avtype = $avtype;
     
            return $this;
        }
     
        /**
         * Get avtype
         *
         * @return string
         */
        public function getAvtype()
        {
            return $this->avtype;
        }
     
        /**
    
         * @var string
         *
         * @ORM\ManyToOne(targetEntity="Autovistatype")
         */
        private $autovistatype;
     
        /**
         * Set autovistatype
         *
         * @param \Alcopa\UnityBundle\Entity\Autovistatype $autovistatype
         * @return Car
         */
        public function setAutovistatype($autovistatype)
        {
            $this->autovistatype = $autovistatype;
     
            return $this;
        }
     
        /**
         * Get autovistatype
         *
         * @return Autovistatype
         */
        public function getAutovistatype()
        {
            return $this->autovistatype;
        }
     
        /**
    
         * @var \DateTime
         *
         * @ORM\Column(name="datemec", type="date")
         */
        private $datemec;
     
        /**
         * Set datemec
         *
         * @param \DateTime $datemec
         * @return Car
         */
        public function setDatemec($datemec)
        {
            $this->datemec = $datemec;
     
            return $this;
        }
     
        /**
         * Get datemec
         *
         * @return \DateTime
         */
        public function getDatemec()
        {
            return $this->datemec;
        }
     
        /**
    
         * @var string
         *
         * @ORM\Column(name="type", type="string", length=8)
         */
        private $type;
     
        /**
         * Set type
         *
         * @param string $type
         * @return Car
         */
        public function setType($type)
        {
            $this->type = $type;
     
            return $this;
        }
     
        /**
         * Get type
         *
         * @return string
         */
        public function getType()
        {
            return $this->type;
        }
     
        /**
    
         * @var string
         *
         * @ORM\Column(name="genre", type="string", length=5)
         */
        private $genre;
     
        /**
         * Set genre
         *
         * @param string $genre
         * @return Car
         */
        public function setGenre($genre)
        {
            $this->genre = $genre;
     
            return $this;
        }
     
        /**
         * Get genre
         *
         * @return string
         */
        public function getGenre()
        {
            return $this->genre;
        }
     
        /**
    
         * @var string
         *
         * @ORM\Column(name="minetype", type="string", length=10)
         */
        private $minetype;
     
        /**
         * Set minetype
         *
         * @param string $minetype
         * @return Car
         */
        public function setMinetype($minetype)
        {
            $this->minetype = $minetype;
     
            return $this;
        }
     
        /**
         * Get minetype
         *
         * @return string
         */
        public function getMinetype()
        {
            return $this->minetype;
        }
     
        /**
    
         * @var integer
         *
         * @ORM\Column(name="co2rate", type="integer")
         */
        private $co2rate;
     
        /**
         * Set co2rate
         *
         * @param integer $co2rate
         * @return Car
         */
        public function setCo2rate($co2rate)
        {
            $this->co2rate = $co2rate;
     
            return $this;
        }
     
        /**
         * Get co2rate
         *
         * @return integer
         */
        public function getCo2rate()
        {
            return $this->co2rate;
        }
     
        /**
    
         * @var string
         *
         * @ORM\Column(name="options", type="text")
         */
        private $options;
     
        /**
         * Set options
         *
         * @param string $options
         * @return Car
         */
        public function setOptions($options)
        {
            $this->options = $options;
     
            return $this;
        }
     
        /**
         * Get options
         *
         * @return string
         */
        public function getOptions()
        {
            return $this->options;
        }
     
        /**
    
         * @ORM\OneToMany(targetEntity="Cycle", mappedBy="car")
         */
        private $cycles;
     
        /**
         * Get cycles
         *
         * @return \Alcopa\UnityBundle\Entity\Cycle[]|ArrayCollection
         */
        public function getCycles()
        {
            return $this->cycles;
        }
     
    }
    Entity Cycle:
    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
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    833
    834
    835
    836
    837
    838
    839
    840
    841
    842
    <?php
     
    namespace Alcopa\Bundle\UnityBundle\Entity;
     
    use Doctrine\ORM\Mapping as ORM;
     
    /**
     * Cycle
     *
     * @ORM\Table()
     * @ORM\Entity(repositoryClass="Alcopa\Bundle\UnityBundle\Entity\CycleRepository")
     */
    class Cycle
    {
     
        public function __construct()
        {
            $this->comments = new ArrayCollection();
            $this->expenses = new ArrayCollection();
            $this->damages = new ArrayCollection();
            $this->pictures = new ArrayCollection();
            $this->documents = new ArrayCollection();
            $this->lots = new ArrayCollection();
        }
     
        /**
    
         * @var integer
         *
         * @ORM\Column(name="id", type="integer")
         * @ORM\Id
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        private $id;
     
        /**
         * Get id
         *
         * @return integer
         */
        public function getId()
        {
            return $this->id;
        }
     
        /**
    
         * @var \DateTime
         *
         * @ORM\Column(name="created_at", type="datetime")
         */
        private $createdAt;
     
        /**
         * Set createdAt
         *
         * @param \DateTime $createdAt
         * @return Cycle
         */
        public function setCreatedAt($createdAt)
        {
            $this->createdAt = $createdAt;
     
            return $this;
        }
     
        /**
         * Get createdAt
         *
         * @return \DateTime
         */
        public function getCreatedAt()
        {
            return $this->createdAt;
        }
     
        /**
    
         * @var \DateTime
         *
         * @ORM\Column(name="updated_at", type="datetime")
         */
        private $updatedAt;
     
        /**
         * Set updatedAt
         *
         * @param \DateTime $updatedAt
         * @return Cycle
         */
        public function setUpdatedAt($updatedAt)
        {
            $this->updatedAt = $updatedAt;
     
            return $this;
        }
     
        /**
         * Get updatedAt
         *
         * @return \DateTime
         */
        public function getUpdatedAt()
        {
            return $this->updatedAt;
        }
     
        /**
    
         * @var integer
         *
         * @ORM\Column(name="policeid", type="bigint")
         */
        private $policeid;
     
        /**
         * Set policeid
         *
         * @param integer $policeid
         * @return Cycle
         */
        public function setPoliceid($policeid)
        {
            $this->policeid = $policeid;
     
            return $this;
        }
     
        /**
         * Get policeid
         *
         * @return integer
         */
        public function getPoliceId()
        {
            return $this->policeid;
        }
     
        /**
    
         * @var integer
         *
         * @ORM\Column(name="status", type="integer")
         */
        private $status;
     
        /**
         * Set status
         *
         * @param integer $status
         * @return Cycle
         */
        public function setStatus($status)
        {
            $this->status = $status;
     
            return $this;
        }
     
        /**
         * Get status
         *
         * @return integer
         */
        public function getStatus()
        {
            return $this->status;
        }
     
     
        /**
    
         * @var boolean
         *
         * @ORM\Column(name="is_litigation", type="boolean")
         */
        private $isLitigation;
     
        /**
         * Set isLitigation
         *
         * @param boolean $isLitigation
         * @return Cycle
         */
        public function setIsLitigation($isLitigation)
        {
            $this->isLitigation = $isLitigation;
     
            return $this;
        }
     
        /**
         * Get isLitigation
         *
         * @return boolean
         */
        public function getIsLitigation()
        {
            return $this->isLitigation;
        }
     
        /**
    
         * @var integer
         *
         * @ORM\Column(name="litigation_state_id", type="integer")
         */
        private $litigationStateId;
     
        /**
         * Set litigationStateId
         *
         * @param integer $litigationStateId
         * @return Cycle
         */
        public function setLitigationStateId($litigationStateId)
        {
            $this->litigationStateId = $litigationStateId;
     
            return $this;
        }
     
        /**
         * Get litigationStateId
         *
         * @return integer
         */
        public function getLitigationStateId()
        {
            return $this->litigationStateId;
        }
     
     
        /**
    
         * @var boolean
         *
         * @ORM\Column(name="is_broken", type="boolean")
         */
        private $isBroken;
     
        /**
         * Set isBroken
         *
         * @param boolean $isBroken
         * @return Cycle
         */
        public function setIsBroken($isBroken)
        {
            $this->isBroken = $isBroken;
     
            return $this;
        }
     
        /**
         * Get isBroken
         *
         * @return boolean
         */
        public function getIsBroken()
        {
            return $this->isBroken;
        }
     
        /**
    
         * @var boolean
         *
         * @ORM\Column(name="is_withvat", type="boolean")
         */
        private $isWithvat;
     
        /**
         * Set isWithvat
         *
         * @param boolean $isWithvat
         * @return Cycle
         */
        public function setIsWithvat($isWithvat)
        {
            $this->isWithvat = $isWithvat;
     
            return $this;
        }
     
        /**
         * Get isWithvat
         *
         * @return boolean
         */
        public function getIsWithvat()
        {
            return $this->isWithvat;
        }
     
        /**
    
         * @var integer
         *
         * @ORM\Column(name="count_salesinroom", type="integer")
         */
        private $countSalesinroom;
     
        /**
         * Set countSalesinroom
         *
         * @param integer $countSalesinroom
         * @return Cycle
         */
        public function setCountSalesinroom($countSalesinroom)
        {
            $this->countSalesinroom = $countSalesinroom;
     
            return $this;
        }
     
        /**
         * Get countSalesinroom
         *
         * @return integer
         */
        public function getCountSalesinroom()
        {
            return $this->countSalesinroom;
        }
     
        /**
    
         * @var integer
         *
         * @ORM\Column(name="count_salesonline", type="integer")
         */
        private $countSalesonline;
     
        /**
         * Set countSalesonline
         *
         * @param integer $countSalesonline
         * @return Cycle
         */
        public function setCountSalesonline($countSalesonline)
        {
            $this->countSalesonline = $countSalesonline;
     
            return $this;
        }
     
        /**
         * Get countSalesonline
         *
         * @return integer
         */
        public function getCountSalesonline()
        {
            return $this->countSalesonline;
        }
     
        /**
    
         * @var integer
         *
         * @ORM\Column(name="argus_cotation", type="integer")
         */
        private $argusCotation;
     
        /**
         * Set argusCotation
         *
         * @param integer $argusCotation
         * @return Cycle
         */
        public function setArgusCotation($argusCotation)
        {
            $this->argusCotation = $argusCotation;
     
            return $this;
        }
     
        /**
         * Get argusCotation
         *
         * @return integer
         */
        public function getArgusCotation()
        {
            return $this->argusCotation;
        }
     
        /**
    
         * @var integer
         *
         * @ORM\Column(name="autovista_cotation", type="integer")
         */
        private $autovistaCotation;
     
        /**
         * Set autovistaCotation
         *
         * @param integer $autovistaCotation
         * @return Cycle
         */
        public function setAutovistaCotation($autovistaCotation)
        {
            $this->autovistaCotation = $autovistaCotation;
     
            return $this;
        }
     
        /**
         * Get autovistaCotation
         *
         * @return integer
         */
        public function getAutovistaCotation()
        {
            return $this->autovistaCotation;
        }
     
        /**
    
         * @var integer
         *
         * @ORM\Column(name="mileage", type="integer")
         */
        private $mileage;
     
        /**
         * Set mileage
         *
         * @param integer $mileage
         * @return Cycle
         */
        public function setMileage($mileage)
        {
            $this->mileage = $mileage;
     
            return $this;
        }
     
        /**
         * Get mileage
         *
         * @return integer
         */
        public function getMileage()
        {
            return $this->mileage;
        }
     
        /**
    
         * @var integer
         *
         * @ORM\Column(name="warranty", type="integer")
         */
        private $warranty;
     
        /**
         * Set warranty
         *
         * @param integer $warranty
         * @return Cycle
         */
        public function setWarranty($warranty)
        {
            $this->warranty = $warranty;
     
            return $this;
        }
     
        /**
         * Get warranty
         *
         * @return integer
         */
        public function getWarranty()
        {
            return $this->warranty;
        }
     
        /**
    
         * @var integer
         *
         * @ORM\Column(name="repair_cost", type="integer")
         */
        private $repairCost;
     
        /**
         * Set repairCost
         *
         * @param integer $repairCost
         * @return Cycle
         */
        public function setRepairCost($repairCost)
        {
            $this->repairCost = $repairCost;
     
            return $this;
        }
     
        /**
         * Get repairCost
         *
         * @return integer
         */
        public function getRepairCost()
        {
            return $this->repairCost;
        }
     
        /**
    
         * @var boolean
         *
         * @ORM\Column(name="repair_history", type="boolean")
         */
        private $repairHistory;
     
        /**
         * Set repairHistory
         *
         * @param boolean $repairHistory
         * @return Cycle
         */
        public function setRepairHistory($repairHistory)
        {
            $this->repairHistory = $repairHistory;
     
            return $this;
        }
     
        /**
         * Get repairHistory
         *
         * @return boolean
         */
        public function getRepairHistory()
        {
            return $this->repairHistory;
        }
     
        /**
    
         * @var boolean
         *
         * @ORM\Column(name="status_certificate", type="boolean")
         */
        private $statusCertificate;
     
        /**
         * Set statusCertificate
         *
         * @param boolean $statusCertificate
         * @return Cycle
         */
        public function setStatusCertificate($statusCertificate)
        {
            $this->statusCertificate = $statusCertificate;
     
            return $this;
        }
     
        /**
         * Get statusCertificate
         *
         * @return boolean
         */
        public function getStatusCertificate()
        {
            return $this->statusCertificate;
        }
     
        /**
    
         * @var boolean
         *
         * @ORM\Column(name="is_salable", type="boolean")
         */
        private $isSalable;
     
        /**
         * Set isSalable
         *
         * @param boolean $isSalable
         * @return Cycle
         */
        public function setIsSalable($isSalable)
        {
            $this->isSalable = $isSalable;
     
            return $this;
        }
     
        /**
         * Get isSalable
         *
         * @return boolean
         */
        public function getIsSalable()
        {
            return $this->isSalable;
        }
     
        /**
    
         * @var boolean
         *
         * @ORM\Column(name="is_firstuse", type="boolean")
         */
        private $isFirstuse;
     
        /**
         * Set isFirstUse
         *
         * @param boolean $isFirstuse
         * @return Cycle
         */
        public function setFirstUse($isFirstuse)
        {
            $this->isFirstuse = $isFirstuse;
     
            return $this;
        }
     
        /**
         * Get isFirstuse
         *
         * @return boolean
         */
        public function getFirstUse()
        {
            return $this->isFirstuse;
        }
     
        /**
    
         * @var integer
         *
         * @ORM\ManyToOne(targetEntity="Site")
         */
        private $site;
     
        /**
         * Set site
         *
         * @param \Alcopa\UnityBundle\Entity\Site $site
         * @return Cycle
         */
        public function setSite($site)
        {
            $this->site = $site;
     
            return $this;
        }
     
        /**
         * Get site
         *
         * @return Site
         */
        public function getSite()
        {
            return $this->site;
        }
     
        /**
    
         * @ORM\OneToMany(targetEntity="Move", mappedBy="cycle")
         */
        private $moves;
     
        /**
         * Get moves
         *
         * @return \Alcopa\UnityBundle\Entity\Move[]|ArrayCollection
         */
        public function getMoves()
        {
            return $this->moves;
        }
     
        /**
    
         * @var integer
         *
         * @ORM\ManyToOne(targetEntity="Supplier")
         */
        private $supplier;
     
        /**
         * Set supplier
         *
         * @param \Alcopa\UnityBundle\Entity\Supplier $supplier
         * @return Cycle
         */
        public function setSupplier($supplier)
        {
            $this->supplier = $supplier;
     
            return $this;
        }
     
        /**
         * Get supplier
         *
         * @return \Alcopa\UnityBundle\Entity\Supplier
         */
        public function getSupplier()
        {
            return $this->supplier;
        }
     
        /**
    
         * @var integer
         *
         * @ORM\ManyToOne(targetEntity="Car")
         */
        private $car;
     
        /**
         * Set car
         *
         * @param \Alcopa\UnityBundle\Entity\Car $car
         * @return Cycle
         */
        public function setCar(Car $car)
        {
            $this->car = $car;
     
            return $this;
        }
     
        /**
         * Get car
         *
         * @return Car
         */
        public function getCar()
        {
            return $this->car;
        }
     
        /**
    
         * @ORM\OneToMany(targetEntity="Comment", mappedBy="cycle")
         */
        private $comments;
     
        /**
         * Get comments
         *
         * @return \Alcopa\UnityBundle\Entity\Comment[]|ArrayCollection
         */
        public function getComments()
        {
            return $this->comments;
        }
     
        /**
    
         * @ORM\OneToMany(targetEntity="Expense", mappedBy="cycle")
         */
        private $expenses;
     
        /**
         * Get expenses
         *
         * @return \Alcopa\UnityBundle\Entity\Expense[]|ArrayCollection
         */
        public function getExpenses()
        {
            return $this->expenses;
        }
     
        /**
    
         * @ORM\OneToMany(targetEntity="Damage", mappedBy="cycle")
         */
        private $damages;
     
        /**
         * Get damages
         *
         * @return \Alcopa\UnityBundle\Entity\Damage[]|ArrayCollection
         */
        public function getDamages()
        {
            return $this->damages;
        }
     
        /**
    
         * @ORM\OneToMany(targetEntity="Picture", mappedBy="cycle")
         */
        private $pictures;
     
        /**
         * Get pictures
         *
         * @return \Alcopa\UnityBundle\Entity\Picture[]|ArrayCollection
         */
        public function getPictures()
        {
            return $this->pictures;
        }
     
        /**
    
         * @ORM\OneToMany(targetEntity="Document", mappedBy="cycle")
         */
        private $documents;
     
        /**
         * Get documents
         *
         * @return \Alcopa\UnityBundle\Entity\Document[]|ArrayCollection
         */
        public function getDocuments()
        {
            return $this->documents;
        }
     
        /**
    
         * @ORM\OneToMany(targetEntity="Lot", mappedBy="cycle")
         */
        private $lots;
     
        /**
         * Get lots
         *
         * @return \Alcopa\UnityBundle\Entity\Lot[]|ArrayCollection
         */
        public function getLots()
        {
            return $this->lots;
        }
     
    }
    Entity Autovistamake
    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
    <?php
     
    namespace Alcopa\Bundle\UnityBundle\Entity;
     
    use Doctrine\ORM\Mapping as ORM;
     
    /**
     * Autovistamake
     *
     * @ORM\Table()
     * @ORM\Entity(repositoryClass="Alcopa\Bundle\UnityBundle\Entity\AutovistamakeRepository")
     */
    class Autovistamake
    {
        /**
    
         * @var integer
         *
         * @ORM\Column(name="id", type="integer")
         * @ORM\Id
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        private $id;
     
        /**
         * Get id
         *
         * @return integer
         */
        public function getId()
        {
            return $this->id;
        }
     
        /**
    
         * @var string
         *
         * @ORM\Column(name="name", type="string", length=255)
         */
        private $name;
     
        /**
         * Set name
         *
         * @param string $name
         * @return Autovistamake
         */
        public function setName($name)
        {
            $this->name = $name;
     
            return $this;
        }
     
        /**
         * Get name
         *
         * @return string
         */
        public function getName()
        {
            return $this->name;
        }
    }
    Form Type:
    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
    <?php
    /**
     * Created by PhpStorm.
     * User: aureliendippe
     * Date: 30/03/15
     * Time: 09:34
     */
     
    namespace Alcopa\Bundle\UnityBundle\Form\Type;
     
    use Symfony\Component\Form\AbstractType;
    use Symfony\Component\Form\FormBuilderInterface;
    use Symfony\Component\OptionsResolver\OptionsResolverInterface;
     
    class CarType extends AbstractType
    {
        public function buildForm(FormBuilderInterface $builder, array $options)
        {
            $builder
                ->add('avmake', 'entity',   array(
                    'class' => 'Alcopa\Bundle\UnityBundle\Entity\Autovistamake',
                    'property' => 'name',
                    'data_class' => 'Alcopa\Bundle\UnityBundle\Entity\Autovistamake',
                ))
                ->add('plate',  'text')
            ;
        }
     
        public function setDefaultOptions(OptionsResolverInterface $resolver)
        {
            $resolver->setDefaults(array(
                'data_class' => 'Alcopa\Bundle\UnityBundle\Entity\Car',
            ));
        }
     
        public function getName()
        {
            return 'cartype';
        }
    }

    Methode Show du Controleur Cycle qui affiche le formulaire

    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
     
        /**
         * @Route("/show/{id}", name="cycle_show")
         * @Template()
         */
        public function showAction( Request $request )
        {
     
            $id = $request->get('id');
     
            /**
             * @var \Alcopa\Bundle\UnityBundle\Entity\Cycle $cycle
             */
            $cycle = $this->getDoctrine()
                ->getRepository('AlcopaUnityBundle:Cycle')
                ->find( $id );
     
            $form = $this->get('form.factory')->createBuilder('form', $cycle)
                ->add('is_salable',     'checkbox')
                ->add('argus_cotation', 'text')
                ->add('car',            new CarType())
                ->add('save',           'submit')
                ->getForm()
            ;
     
     
            if ($form->handleRequest($request)->isValid()) {
                $data = $form->getData();
                $em = $this->getDoctrine()->getManager();
                $em->persist($data);
                $em->flush();
                return $this->redirect($this->generateUrl('cycle_show', [
                    'id' => $id,
                ]));
            }
     
     
            return array(
                'CycleFrm' => $form->createView(),
                'id' => $id,
                'common' => $this->getCommon()
            );
        }

    Merci pour votre aide !

  2. #2
    Membre expérimenté
    Homme Profil pro
    Inscrit en
    Septembre 2009
    Messages
    875
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Septembre 2009
    Messages : 875
    Points : 1 313
    Points
    1 313
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
       * @ORM\Column(name="avmake", type="string", length=255)
       private $avmake;
     
        * @ORM\ManyToOne(targetEntity="Autovistamake")
         */
        private $autovistamake;
    avmake est un string dans ton entité doctrine

  3. #3
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Octobre 2006
    Messages
    39
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2006
    Messages : 39
    Points : 25
    Points
    25
    Par défaut
    Bonjour et merci pour ta réponse.

    Tu as raison, (en fait le but final est de sauvegardé à la fois l'ID et le text directement dans Car pour évité d'avoir à faire des jointures en permanence).
    Pour testé j'ai modifié le type du champ avmake pour le mettre en Integer et ai fait un doctrine:schema:update.
    Ca n'a rien changé, toujours l'erreur
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    An exception occurred while executing 'UPDATE Car SET avmake = ? WHERE id = ?' with params [{}, 1]:
     
    Catchable Fatal Error: Object of class Alcopa\Bundle\UnityBundle\Entity\Autovistamake could not be converted to string
    D'ailleurs ca me parait assez normal ... même si effectivement les champs n'étaient pas du même type, il devait tout de même le mettre la valeur de l'ID du Select dans les paramètres de la requête.



    Citation Envoyé par gototog Voir le message
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
       * @ORM\Column(name="avmake", type="string", length=255)
       private $avmake;
     
        * @ORM\ManyToOne(targetEntity="Autovistamake")
         */
        private $autovistamake;
    avmake est un string dans ton entité doctrine

  4. #4
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Octobre 2006
    Messages
    39
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2006
    Messages : 39
    Points : 25
    Points
    25
    Par défaut
    Bon, j'ai réglé mon problème ... l'entity Autovistamake doit avoir une méthode "__ToString" (qui renvoie ce que je veux mettre en base) pour que ca fonctionne.

  5. #5
    Membre expérimenté
    Homme Profil pro
    Inscrit en
    Septembre 2009
    Messages
    875
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Septembre 2009
    Messages : 875
    Points : 1 313
    Points
    1 313
    Par défaut
    Tu as raison, (en fait le but final est de sauvegardé à la fois l'ID et le text directement dans Car pour évité d'avoir à faire des jointures en permanence).
    J me permet de réagir, si tu veux dénormaliser tes schemas va sur du NOSql au lieu de faire des choses horribles.
    Le cout de la flemme de faire deux lignes de code de jointure dépasse largement le cout des problèmes de maintenabilité que ta solution va engendrer. Rajouter en plus le temps de bidouillage comme ici..

    Pour revenir à ton problème, ton champs de type entity doit être sur l'attribut qui fait la clé étrangère.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    ->add('autovistamake', 'entity',   array(
                    'class' => 'Alcopa\Bundle\UnityBundle\Entity\Autovistamake',
                    'property' => 'name',
                    'data_class' => 'Alcopa\Bundle\UnityBundle\Entity\Autovistamake',
                ))

  6. #6
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Octobre 2006
    Messages
    39
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2006
    Messages : 39
    Points : 25
    Points
    25
    Par défaut
    Si je fais ainsi c'est peut-être qu'il y a des contraintes / optimisations nécessaires dans mon modèle de données.

  7. #7
    Membre expérimenté
    Homme Profil pro
    Inscrit en
    Septembre 2009
    Messages
    875
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Septembre 2009
    Messages : 875
    Points : 1 313
    Points
    1 313
    Par défaut
    Si tu passes ici juste pour qu'on debug ton code sans mettre en évidence des lacunes de conception je vois pas l’intérêt de participer :]
    Edited: Sur un site d'entraide il y a beaucoup de personne qui poste des trucs crades, je préfère prendre le risque de froisser ta sensibilité que de laisser des personnes s'inspirer de ça

Discussions similaires

  1. fatal error -2147467259 lors d'une requête SQL avec Mysql
    Par Spartanjohn dans le forum ADO.NET
    Réponses: 2
    Dernier message: 18/03/2013, 17h23
  2. Erreur lors d'un enregistrement Sql Server distant
    Par angus9 dans le forum MS SQL Server
    Réponses: 3
    Dernier message: 27/12/2010, 18h50
  3. [SQl + Access] defénir la taille d'un champ du type integer
    Par Bourak dans le forum Bases de données
    Réponses: 1
    Dernier message: 12/01/2007, 10h19
  4. [SQL] Faire un Distinct en incluant un champ de type Memo
    Par Pedro dans le forum Bases de données
    Réponses: 30
    Dernier message: 23/03/2006, 19h08
  5. Réponses: 3
    Dernier message: 28/11/2003, 21h26

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo