2011-06-28 24 views
0

SQLの外部キー制約が失敗して4日間苦労しています。私は理由を知りません。私はその件について私ができることをすべて読んだので、すべてがうまくいくように思えます。ここで SQLエラーの外部キー制約

は私のschema.ymlの

Soiree: 
    actAs: { Timestampable: ~ } 
    columns: 
    titre:  { type: string(255), notnull: true } 
    description: { type: blob(), notnull: true } 
    adresse: { type: string(255), notnull: true, unique: true } 
    code_postal: {type: integer, notnull: true } 
    ville: {type: string(255), notnull:true} 
    date: {type: timestamp, notnull: true } 
    type_id: {type: integer, notnull: true } 
    flyer: {type: string(255), notnull:true } 
    is_visible: { type: boolean, notnull:true, default:0 } 
    user_id: {type:integer, notnull: true} 
relations: 
    sfGuardUser: {onDelete: CASCADE, local: user_id, foreign: id, foreignAlias: Users} 
    Type: {onDelete: CASCADE, local: type_id, foreign: id, alias: Types, class: Type, refClass: Soiree} 

Type: 
    columns: 
    titre: {type: string(255), notnull: true} 

Invitation: 
    actAs: { Timestampable: ~ } 
    columns: 
    titre:  { type: string(255), notnull: true } 
    description: { type: blob(), notnull: true } 
    image:  { type: string(255), notnull: true } 
    is_sent: {type: boolean, notnull:true, default:0} 
    adresse:   { type: string(255) } 
    code_postal:   { type: string(255) } 
    code_QR: {type: string(255), notnull: true } 
    invites_id: {type:integer } 
    user_id: {type:integer, notnull: true} 
    groupe_invites_id : {type:integer, notnull: true } 
    soiree_id: {type:integer, notnull:true} 
    relations: 
    Invites: { onDelete: CASCADE, local: invites_id, foreign: id, alias: invite, class: Invites, refClass: Invitation } 
    Groupe_invites: { onDelete: CASCADE, local: groupe_invites_id, foreign: id, alias: invit_groupes, class: Groupe_invites, refClass: Invitation } 
    sfGuardUser: {onDelete: CASCADE, local: user_id, foreign: id, foreignAlias: Users} 
    Soiree: { onDelete: CASCADE, local: soiree_id, foreign: id, alias :Soirees, class: Soiree, refClass: Invitation } 



Groupe_invites: 
    actAs: { Timestampable: ~ } 
    columns: 
    titre:  { type: string(255), notnull: true } 
    description:  { type: string(255), notnull: true, unique: true } 
    invites_id:  { type: integer, notnull: true } 
    soiree_id: { type: integer } 
    user_id: {type:integer, notnull: true} 
    relations: 
    Invites: 
     onDelete: CASCADE 
     local: invites_id 
     foreign: id 
     alias: invites 
     class: Invites 
     refClass: Groupe_invites 
    sfGuardUser: {onDelete: CASCADE, local: user_id, foreign: id, foreignAlias: Users} 
    Soiree: { onDelete: CASCADE, local: soiree_id, foreign: id, alias: Soiree, class: Soiree, refClass: Groupe_invites } 

Invites: 
    columns: 
    nom: { type: string(255), notnull: true } 
    prenom: { type: string(255), notnull: true } 
    age: {type: integer, notnull : true } 
    email: {type: string(255), notnull: true, unique: true } 
    adresse: {type: blob(), notnull: true } 
    telephone: {type: integer(255), notnull: true } 
    soiree_id: {type: integer, notnull: true } 
    user_id: {type:integer, notnull: true} 
    relations: 
    sfGuardUser: {onDelete: CASCADE, local: user_id, foreign: id, foreignAlias: Users} 
    Soiree: { onDelete: CASCADE, local: soiree_id, foreign: id, alias: Soiree_invite, class: Soiree, refClass: Invites } 

Organisateur: 
    actAs: {Timestampable: ~ } 
    columns: 
    nom: {type: string(255), notnull: true } 
    prenom: {type: string(255), notnull: true } 
    age: {type: integer, notnull: true } 
    description: {type: blob(), notnull: true } 
    photo: {type: string(255), notnull: true } 
    user_id: {type:integer, notnull: true} 
    relations: 
    sfGuardUser: {onDelete: CASCADE, local: user_id, foreign: id, foreignAlias: Users} 


Image: 
columns: 
    titre: {type: string(255), notnull: true } 
    description: {type: string(255), notnull: true } 
    lien: {type: string(255)} 
    album_id: {type: integer} 
    user_id: {type: integer} 
relations: 
    Album: {onDelete: CASCADE, local: album_id, foreign: id, alias: Albums, class:Album, refClass:Image} 
    sfGuardUser: {onDelete: CASCADE, local: user_id, foreign: id} 


Album: 
columns: 
    titre: {type: string(255), notnull: true } 
    description: {type: blob(), notnull: true } 
    user_id: {type:integer, notnull: true} 
relations: 
    sfGuardUser: {onDelete: CASCADE, local: user_id, foreign: id} 

であると私はタイプのエラーを持っている:

SQLSTATE [23000]:整合性制約違反:1452追加または子行を更新できません:外部キーを制約が失敗した(soireeを。invitation、CONSTRAINT invitation_ibfk_1 FOREIGN KEY(invites_id)DELETE CASCADE ON invitationid)を参照)

Iレアちょっとこれに助けが必要です、ありがとう!

+0

あなたが備品をアップロードしようとしているときにこのエラーメッセージが発生しますか? – Tom

答えて

0

私は通常、テーブルにID列を追加します。それは理にかなってテーブルにこれを適用します。

ID:{タイプ:整数、プライマリー:真、自動インクリメント:真}

+0

こんにちは、まず、私の記事を読んで答える時間をとってくれてありがとう。不幸にして、あなたが私に言いました変更を加えましたが、何も変わっていません、私はまだ同じエラーを受け取ります... – Lambivist

+0

あなたは外国のIDを持つテーブルを確認してください。たとえば、Groupe_Invitesテーブルの場合:Soiree:{onDelete:CASCADE、local:soiree_id、foreign:id、別名:Soiree、クラス:Soiree、refClass:Groupe_invites}参照しようとしているので、SorieeテーブルにIDがあることを確認してくださいそれは外国人経由で:イド – daSn0wie