如何在Symfony2项目中删除实体类 [英] How to remove an entity class in a Symfony2 project

查看:100
本文介绍了如何在Symfony2项目中删除实体类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们最初设计项目时,到目前为止,我们有几个实体尚未使用(并且我们不打算在不久的将来实现它们)。因此,我想将其从我的项目中删除。我将这样进行操作(手动执行所有步骤):

When we initially designed our project, we had a couple of entities that to date are unused (and we don't plan to implement them in the near future). Ergo I want to remove them from my project. I would proceed like this (all steps manually performed):


  1. 从我当前使用的实体中删除所有关系。

  2. 删除文档ORM文件 src / Resources / config / doctrine

  3. 从<$ c $中删除类PHP文件c> src / Entity

  4. 从数据库中删除表

  1. Remove all relations from my currently used entities.
  2. Delete the doctrime ORM file src/Resources/config/doctrine
  3. Delete the class PHP file from src/Entity
  4. Remove the table from the database



<我想知道的是:是否有任何例程(例如控制台命令)可以支持此过程?例如,如果我运行

What I would like to know: Are there any routines (e.g. console commands) that may support this procedure? For example, if I run

php app/console doctrine:schema:update --dump-sql

在删除了所有关系并删除了文件之后,我得到了删除相应表的SQL语句吗?

after having removed all relations and deleted the files, that I get the SQL statement that removes the according table(s)?

推荐答案

您删除实体的步骤是可以的。

Your steps to delete an entity are OK.

您可以不要从教义中删除表,因为教义不知道该表。看看这个问题:

You can't remove a table from Doctrine, as Doctrine doesn't know about it. Have a look at this question:

使用Doctrine2和Symfony2删除表

这篇关于如何在Symfony2项目中删除实体类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆