I’m working with an existing database schema, and trying to setup two Doctrine models with a Many to Many relationship, as described in this document
When creating tables from scratch, I have no trouble getting this working. However, the existing join tables use a different naming convention that what’s described in the Doctrine document. Specifically
Table 1
--------------------------------------------------
table_1_id
....other columns....
Table 2
--------------------------------------------------
table_2_id
....other columns....
Join Table
--------------------------------------------------
fktable1_id
fktable_2_id
Basically, the previous developers prefaced all foreign keys with an fk.
From the examples I’ve seen and some brief experimenting with code, it appears that Doctrine 1.2 requires that the join table use the same column names as the tables it’s joining in
Is my assumption correct?
If so, has the situation changed in Doctrine 2?
If the answers to either of the above are true, how do you configure the models so that all the columns “line up”
Take a look at the docs regarding N:M relations.
When you look at
from the docs, you see that is is up to you how you name the column in your join model.
Since you have an existing database, why not generate the models via Doctrine? The API shows you the needed options for this. I used that myself and it works pretty good. Sometimes you may need some cleanups if you have a compliacted structure but the generated files are a very good start.