symfony2-创建提交表单生成数据过程,symfony2-表单
一、”一对多“关系
表shop(一)
表comment(多)
保存有shop_id
orm关系
Shop.orm.xml
Comment.orm.xml
二、首先我们来手动生成shop 和comment的关系
第一种情况 (可以生成)
controller中
可以生成表,对应关系
表shop
表:comment
因为这里shop表中的comments,其实并没有在shop表中有字段,这里只是一个记号,表示用来取comments方便。比如$shop->getComments();而且添加comment时方便。
第二种情况 (不可以生成)
如果改变addComments函数呢
不能生成表对应关系
表:shop
表:comment
为什么呢?
因为comment表id并没有和shop关联起来(即真实comment表中没有存上shop的id)
第三中情况:(可以生成表关系)
表:shop
表:comment
直接用往comment中添加shop
好了,其实还有“多对多”关系?
提交表时,如何自动生成一对多时关系?
下次说吧

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

Atom editor mac version download
The most popular open source editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment