使用 symfony2 和教义从现有数据库生成单个实体 [英] Generating a single Entity from existing database using symfony2 and doctrine

查看:16
本文介绍了使用 symfony2 和教义从现有数据库生成单个实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 Symfony2 控制台工具从数据库生成单个实体?

Is it possible to generate a single entity from database using the Symfony2 console tool?

在编码过程中,我不得不添加一个表,并对现有的实体类进行了修改.所以我不希望我的所有实体都重新生成.

In the middle of coding I had to add a table and there are modifications made to the existing entity classes. So I don't want all my entities regenerated.

任何建议将不胜感激!

推荐答案

我遇到了同样的问题,你必须这样做:

I had the same problem, you've to do this way:

php app/console doctrine:mapping:convert metadata_format 
    ./src/App/MyBundle/Resources/config/doctrine 
    --from-database 
    --filter="Yourtablename"

然后

php app/console doctrine:mapping:import AppMyBundle 
    metadata_format --filter="Yourtablename"

其中 metadata_format 是您要生成的文件结尾(例如 xml、yml、注释)

Where metadata_format is the file ending you want to generate (e.g. xml, yml, annotation)

最后

php app/console doctrine:generate:entities AppMyBundle --no-backup

就像这个学说只会加载你需要的实体.请注意必须使用 CamelCase 的过滤器!

Like this doctrine will load only the entity you need. Just be carefull on the filter you must use the CamelCase !

希望对你有帮助

这篇关于使用 symfony2 和教义从现有数据库生成单个实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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