First, "one-to-many" relationship
Table Shop (i)
Table Comment (Multi)
Save with SHOP_ID
Second, we first to manually generate shop and comment relationship
First case (can be generated)
Controller in
Tables can be generated, corresponding relationships
Table Shop
Table: Comment
Because the shop table in the comments, in fact, there is no field in the shop table, here is just a sign, to take comments convenient. such as $shop->getcomments (), and it is convenient to add comment.
Second case (cannot be generated)
What if I change the addcomments function?
Table correspondence cannot be generated
Table: Shop
Table: Comment
Why is it?
Because the comment table ID is not associated with the shop (that is, the ID of the shop is not stored in the real comment table)
Scenario Three: (Table relationships can be generated)
Table: Shop
Table: Comment
Add shop directly to the comment
Well, actually there's a "many-to-many" relationship?
How do I automatically generate a one-to-multiple relationship when I submit a table?
Say it next time.
The above describes the symfony2-to create a submission form to generate data, including the content, I hope to be interested in PHP tutorial friends helpful.