Hi there!
I'm trying to build a model for content pages on my site, and i gave it a self reference named 'Related Page'. Now if i build my models and try to create a new page in the admin generator everything works fine. If i give the page a related page (or more) it works fine too, but if i go to the other page and try to edit the references symfony crashes:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '2-2' for key 'PRIMARY'
I checked it in phpmyadmin and noticed that in the association table i have 2 ids (id1 and id2) and only the first id is a link:
(sorry I couldn't paste a link)
I tried to give an 'id' field to the association table so i had 3 fields (id, id1, id2), and i saw that when I update the relations in the other page (page2 to page1 and page2 to page3), it is creating the relations for that page (page2 to page1 and page3) and it is deleting the old relations (it was page1 to page2 and page1 to page3) and the final relations i have in the association table is page1 to page 1 (???) page 2 to page1 and page2 to page3.
My models are:
Page:
//...
relations:
RelatedPages:
class: Page
local: id1
foreign: id2
refClass: RelatedPage
equal: true
RelatedPage:
columns:
id1:
type: integer(4)
primary: true
unsigned: true
notnull: true
id2:
type: integer(4)
primary: true
unsigned: true
notnull: true
I'm using the symfony admin generator. Do I have to write some code to handle this, or am I doing something wrong?
I checked the doctrine documentation: link text
and it seems that everything is OK.