How do I setup a join table with extra columns, or a many-to-many association with additional properties, in Doctrine 2?
相关问题
- How to add optgroups to a django ModelMultipleChoi
- C# How do I create code to set a form back to defa
- VBA Getting date from properties of a text file
- How to represent a categorized many-to-many databa
- Lifecycle Callback Issue When Extending FOSUserBun
相关文章
- Does JavaScript allow getters and setters?
- Notice: Undefined property - how do I avoid that m
- Using the typical get set properties in C#… with p
- Symfony : Doctrine data fixture : how to handle la
- Mocking nested properties with mock
- Is there a way to modify the entity mapping config
- Python - What is a lazy property?
- Get random records with Doctrine
First off, let me explain that this does not exist:
A join table (also known as a junction table or cross-reference table) is a table that links 2 (or more) other tables together within the same database by primary key. This means that a join table will only contain foreign keys, there is no place for these extra columns.
So when you need extra columns in such a table, it is no longer just a "link" between other tables, but becomes a real table on its own!
In terms of Doctrine 2, you no longer have a many-to-many association between 2 entities, but get a one-to-many/many-to-one association between 3 entities.
Continue reading here for more details explanations:
In the second article, I suggest a minor update. Instead of the full event, use a LifecycleCallback within the entity itself: