如何从symfony2中的现有表生成实体? [英] How to generate entity from existing table in symfony2?

查看:25
本文介绍了如何从symfony2中的现有表生成实体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些字段的表my_table".我想在 MyBundle 中使用my_table"生成实体.但我不想在 MyBundle 中重新创建所有实体.我该怎么做?

I have table "my_table" with some fields. I want generate Entity in MyBundle used "my_table". But I don't want recreate all entities in MyBundle. How can I do this?

推荐答案

这是你可以做到的方法,

Here is the way you can do it,

第一步,让 Doctrine 内省数据库并生成相应的 xml 或 yml 元数据文件.

First step, ask Doctrine to introspect the database and generate the corresponding xml or yml metadata files.

php app/console doctrine:mapping:convert [xml|yml] Path/To/MyBundle/Resources/config/doctrine/metadata/orm --from-database --force --filter=MyTable

第二步,通过执行以下两个命令,让 Doctrine 导入架构并构建相关实体类.

Second step, ask Doctrine to import the schema and build related entity classes by executing the following two commands.

php app/console doctrine:mapping:import MyBundle [xml|yml|annotation] --filter=MyTable

php app/console doctrine:generate:entities Path\To\MyBundle\EntityFolder\\MyTable

查看文档的如何从现有数据库生成实体部分

这篇关于如何从symfony2中的现有表生成实体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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