Précédent   Forum des professionnels en informatique > PHP > Bibliothèques et frameworks > symfony
symfony Forum d'entraide sur le framework PHP symfony. Avant de poster : cours symfony et FAQ symfony
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 07/12/2011, 08h32   #1
Invité de passage
 
Vincent Maurel
Inscription : novembre 2010
Messages : 19
Détails du profil
Informations personnelles :
Nom : Vincent Maurel

Informations forums :
Inscription : novembre 2010
Messages : 19
Points : 2
Points : 2
Par défaut Erreur d'insertion SQL Error Code: 1072. Key column 'aptinscription_id' doesn't exist in table

Bonjour à tous

J'ai un problème à l'insertion du sql.

voilà mon schema.yml:

Code :
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
 
aptevenement:
  columns:
    titre_evenement: string
    desciption: string
    lieu: string
    date_evenement: date
    date_cloture_inscriptions: date
    nb_joueurs_max: integer
    image_fond_confirmation: string
  relations:
    aptinscription:
      foreignAlias: Evenement
 
aptinscription:
  columns:
    nom: 
      type: string 
      notnull: true
    prenom:
      type: string 
      notnull: true
    pseudo:  
      type: string 
      notnull: false
    date_naissance:
      type: date 
      notnull: true
    email:
      type: string
      notnull: true
    ville:
      type: string 
      notnull: true
    code_securite:
      type: string
      notnull: true
    aptetatreservation_id:
      type: integer
      notnull: true
    aptevenement_id:
      type: integer
      notnull: true
 
aptetatreservation:
  columns:
    libelle:
      type: string 
      notnull: true
  relations:
    aptinscription:
      foreignAlias: EtatReservation
Je ne pense pas avoir fait d'erreur en le créant.
Il me génère ce sql: (après un cc et un build-model)

Code :
1
2
3
4
5
6
 
CREATE TABLE aptetatreservation (id BIGINT AUTO_INCREMENT, libelle TEXT NOT NULL, INDEX aptinscription_id_idx (aptinscription_id), PRIMARY KEY(id)) ENGINE = INNODB;
 
CREATE TABLE aptevenement (id BIGINT AUTO_INCREMENT, titre_evenement TEXT, desciption TEXT, lieu TEXT, date_evenement DATE, date_cloture_inscriptions DATE, nb_joueurs_max BIGINT, image_fond_confirmation TEXT, INDEX aptinscription_id_idx (aptinscription_id), PRIMARY KEY(id)) ENGINE = INNODB;
 
CREATE TABLE aptinscription (id BIGINT AUTO_INCREMENT, nom TEXT NOT NULL, prenom TEXT NOT NULL, pseudo TEXT, date_naissance DATE NOT NULL, email TEXT NOT NULL, ville TEXT NOT NULL, code_securite TEXT NOT NULL, aptetatreservation_id BIGINT NOT NULL, aptevenement_id BIGINT NOT NULL, PRIMARY KEY(id)) ENGINE = INNODB;
et quand j'exécute ce sql dans mon Mysql j'obtiens l'erreur:

Code :
1
2
Error Code: 1072. Key column 'aptinscription_id' doesn't exist in table
ça fait 3/4h que je cherche mon erreur, je ne la vois pas si quelqu'un la voit , ou a un conseil à me donner je suis preneur

merci d'avance
BritsFan est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/12/2011, 10h53   #2
Membre chevronné
 
Avatar de Herode
 
Développeur Web
Inscription : mars 2005
Messages : 771
Détails du profil
Informations personnelles :
Localisation : France, Savoie (Rhône Alpes)

Informations professionnelles :
Activité : Développeur Web

Informations forums :
Inscription : mars 2005
Messages : 771
Points : 790
Points : 790
Je ne vois pas la clé étrangère vers aptinscription dans ton schéma pour aptevenement. Doctrine génère la clé locale quand tu ne la déclares pas explicitement mais pas les clés étrangères.
Herode est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/12/2011, 11h44   #3
Membre chevronné
 
Avatar de kenny.kev
 
Homme
Inscription : janvier 2007
Messages : 575
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 27
Localisation : France, Indre et Loire (Centre)

Informations professionnelles :
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : janvier 2007
Messages : 575
Points : 690
Points : 690
Envoyer un message via MSN à kenny.kev
Il y a aussi le problème que l'ordre des requête c'est pas correcte la table aptinscription ce crée en dernier alors qu'il y a des clés étrangères sur celle-ci.

Herode à raison en déclarent les clé étrangères l'ordre devrais ce rétablir
kenny.kev est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/12/2011, 13h48   #4
Invité de passage
 
Vincent Maurel
Inscription : novembre 2010
Messages : 19
Détails du profil
Informations personnelles :
Nom : Vincent Maurel

Informations forums :
Inscription : novembre 2010
Messages : 19
Points : 2
Points : 2
merci de vos réponses

effectivement j'ai confondu, il fallait déclarer les relations seulement sur les tables qui ont les clés étrangères, j'ai inversé, ça marche maintenant

le schéma corrigé:

Code :
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
aptevenement:
  columns:
    titre_evenement: string
    desciption: string
    lieu: string
    date_evenement: date
    date_cloture_inscriptions: date
    nb_joueurs_max: integer
    image_fond_confirmation: string
 
aptinscription:
  columns:
    nom: 
      type: string 
      notnull: true
    prenom:
      type: string 
      notnull: true
    pseudo:  
      type: string 
      notnull: false
    date_naissance:
      type: date 
      notnull: true
    email:
      type: string
      notnull: true
    ville:
      type: string 
      notnull: true
    code_securite:
      type: string
      notnull: true
    aptetatreservation_id:
      type: integer
      notnull: true
    aptevenement_id:
      type: integer
      notnull: true
  relations:
    aptetatreservation:
      foreignAlias: Inscriptions
    aptevenement:
      foreignAlias: Inscriptions
 
aptetatreservation:
  columns:
    libelle:
      type: string 
      notnull: true
merci
BritsFan est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 22h07.


 
 
 
 
Partenaires

Hébergement Web