Home > Backend Development > PHP Tutorial > symfony2-Create a submit form to generate data process

symfony2-Create a submit form to generate data process

WBOY
Release: 2016-08-08 09:24:14
Original
1023 people have browsed it

1. "One-to-many" relationship

Table shop (1)

Table comment (many)

Save shop_id

2. First, let’s manually generate shop and comment Relationship

The first case (can be generated)

controller

can generate a table, corresponding relationship

table shop

table: comment

Because The comments in the shop table here do not actually have a field in the shop table. It is just a mark to indicate that it is convenient to retrieve comments. For example, $shop->getComments(); is also convenient when adding comments.

Second case (cannot be generated)

What if the addComments function is changed

Cannot generate table correspondence

Table: shop

Table: comment

Why?

Because the comment table id is not associated with the shop (that is, the shop id is not stored in the real comment table)

The third situation: (table relationships can be generated)

table : shop

table: comment

directly add shop

to the comment

Okay, in fact, there is also "many-to-many" "relation?

How to automatically generate a one-to-many relationship when submitting a table?

Let’s talk about it next time

The above introduces the process of symfony2-creating a submission form to generate data, including aspects of the process. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template