php - Doctrine 2: cannot set OneTo Many relation correctly -
I have 2 entities: There are many unidirectional relationships for interview with interview and comment comment.
Here is my YAML mapping file for comment:
entities \ comment: type: unit table: comment repositoryClass: data collection location \ commentRepository areas: id: type: integer id: true generator: strategy : Auto parentid: Type: Integer Faucet: False column: parentid isactive: Type: W Credits: False column: isactive isremoved: type: integer faucet: false column: isremoved removaldate: type: datetime faucet: true column: removaldate user_name: type: string length: 255 faucet: false column: user_name user_email: type: string key Length: 255 Faucet: false column: user_email user_avatar: type: string length: 255 faucet: false column: user_avatar note: type: text faucet: false column: comment creation: type: date time zero: wrong column: build rating: type Falcon: False: False Here is my yaml mapping file for the interview:
Institutions: Interviews: Type: Unit Table: Interview Repository Class: Repositories \ Interview RepoOri Fields : Id: type: integer id: true generator: strategy: auto isremoved: type: integer faucet: false column: isremoved removaldate: type: datetime faucet: true column: removaldate creationdate: type: datetime faucet: false column: creationdate rating: type Do: string length: 255 n Eligible: Correct column: anonsphoto Interview title: Type: Integer faucet: false anonstitle: Type: String length: 1000 Faucet: Wrong column: Unauthenticated anus: Type: text fable: Wrong column: String length: 1000 tap : False column: interviewtitle interview: type: text tap: true column: interview interviewphoto: type: string length: 255 faucet: true column: interviewphoto manyToMany: comments: targetEntity: comment joinTable: name: interviews_comments joinColumns: interview_id: referenced Invalid name: id inverseJoinColumns: comment_id: referenced ColumnName: id unique: true So after loading the schema to the database, I have 3 tables; 2 of them are institutions, for a relation And there are only 2 columns in it: interview_id, comment_id but after continuing the comments objects for some interviews I do not see anything in the host table. Can not know why
There are several unidirectional relationships in the interview with the comment.
not because you have manyToMany in entities \ interview , not directionless oneToMany Defined in this regard as Many many mappings require an included table because there can be many comments in a interview and a Comment can be many interviews in . This problem can not be left with additional attributes in database tables, so an additional mapping table has been created. Solution : If you have a interview with many comments , but in a comment There is a interview , you have to correct the mapping in the HTML code interview {/ code}> Ekatomoni without joinTable (as You have been defined and created).
Comments
Post a Comment