使用symfony2和doctrine从现有数据库生成单个实体 [英] Generating a single Entity from existing database using symfony2 and doctrine
本文介绍了使用symfony2和doctrine从现有数据库生成单个实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用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.
任何建议将不胜感激。
推荐答案
问题,您必须这样做:
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,annotation)
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
像这样的doctrine将只加载你需要的实体。只要在过滤器上小心就必须使用CamelCase!
Like this doctrine will load only the entity you need. Just be carefull on the filter you must use the CamelCase !
希望这会帮助你
这篇关于使用symfony2和doctrine从现有数据库生成单个实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文