symfony2-创建提交表单生成数据过程,symfony2-表单
Jun 13, 2016 am 09:04 AMsymfony2-创建提交表单生成数据过程,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 Article

Hot tools Tags

Hot Article

Hot Article Tags

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

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Use ddrescue to recover data on Linux

Open source! Beyond ZoeDepth! DepthFM: Fast and accurate monocular depth estimation!

Google is ecstatic: JAX performance surpasses Pytorch and TensorFlow! It may become the fastest choice for GPU inference training

The vitality of super intelligence awakens! But with the arrival of self-updating AI, mothers no longer have to worry about data bottlenecks

Slow Cellular Data Internet Speeds on iPhone: Fixes

The U.S. Air Force showcases its first AI fighter jet with high profile! The minister personally conducted the test drive without interfering during the whole process, and 100,000 lines of code were tested for 21 times.

The first robot to autonomously complete human tasks appears, with five fingers that are flexible and fast, and large models support virtual space training

Alibaba 7B multi-modal document understanding large model wins new SOTA
