问题描述
如何使用 Doctrine2 和 Symfony2 删除表?我已经生成了实体并更新了架构,现在我想删除这个结构.
How can I delete table using Doctrine2 and Symfony2? I've generated entities and updated schema, now I want to delete this structure.
推荐答案
不确定我是否正确理解了您的问题.您删除了一个实体并想从数据库中删除它生成的表?如果是这样:
Not sure if I understood your question correctly. You deleted an entity and want to delete also its generated table from database? If so:
你不能这样做,因为 Doctrine2 只关心它知道的表——这意味着那些由实体表示的表.由于您从应用程序中删除了一些实体,Doctrine 不再认为该表属于您的应用程序.存在同一个数据库中存在不同应用的不同表的情况.如果 Doctrine 删除它们只是因为它对它们一无所知,那将毫无意义.这将是种族主义......但反对桌子.
You can't do it, because Doctrine2 only cares about tables it knows - that means the ones that are represented by Entities. Since you deleted some Entity from your application, Doctrine no longer thinks the table belongs to your application. There are situations when there are different tables of different applications in the same database. It wouldn't make sense if Doctrine deleted them just because it doesn't know anything about them. It would be racist... but against tables.
如果您只想以编程方式删除表,您可以使用原始查询.据我所知,Doctrine 没有任何删除表的方法.或者,您也可以手动完成.
If you just want to drop tables programmatically, you can use raw query. As far as I know, Doctrine doesn't have any method for dropping tables. Or as an alternative, you can do it by hand.
这篇关于使用 Doctrine2 和 Symfony2 删除表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)