I'm working with Symfony 1.2 (can't update, it's not up to me) with Propel as ORM. I'm having a bizarre problem with my many-to-many relations.
Let's say you have two tables A
and B
, and a many-to-many relation A_has_B
. Let's say I have an a
entity in A
, a b
entity in B
, and a relation in A_has_B
which PK is (a_id, b_id)
. Now, if I update b
entity (not its id, but another field which is not its PK) using symfony admin generated modules, then (a_id, b_id)
is dropped from the database.
This only happens using Symfony backend. It DOESN'T happen using phpmyadmin, where I can update a
and b
without loosing (a_id, b_id)
relation.
All tables are MySQL/InnoDB. Columns A_id
and B_id
in A_has_B
are foreign keys pointing to A
and B
id's. I have ON DELETE CASCADE
and ON UPDATE CASCADE
in both columns.
Thank you very much for your help.
UPDATE: Here is the yml schema, for three tables Team
and Participants
and its relation
propel:
_attributes:
package: lib.model
defaultIdMethod: native
team:
_attributes: { phpName: Team }
id: { type: INTEGER, size: '11', primaryKey: true, autoIncrement: true, required: true }
name: { type: VARCHAR, size: '255', required: true }
description: { type: LONGVARCHAR, required: false }
participant:
_attributes: { phpName: Participant }
id: { type: INTEGER, size: '11', primaryKey: true, autoIncrement: true, required: true }
name: { type: VARCHAR, size: '255', required: true }
team_has_participant:
_attributes: { phpName: TeamHasParticipant }
team_id: { type: INTEGER, size: '11', primaryKey: true, required: true, foreignTable: team, foreignReference: id, onDelete: CASCADE, onUpdate: CASCADE }
participant_id: { type: INTEGER, size: '11', primaryKey: true, required: true, foreignTable: participant, foreignReference: id, onDelete: CASCADE, onUpdate: CASCADE }
_indexes: { participant_id: [participant_id] }
Say I update description
field in a team
entity, then I'm loosing all the team_has_participant
relations that had that foreign team
entity.