如何使用doctrine-orm-module和zf2从数据库模式生成实体 [英] How to generate entities from database schema using doctrine-orm-module and zf2

查看:120
本文介绍了如何使用doctrine-orm-module和zf2从数据库模式生成实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 doctrine / doctrine-orm-module: 0.7.0 使用ZF2。

I am using "doctrine/doctrine-orm-module": "0.7.0" with ZF2.

创建实体后,我通常会按照以下命令运行以根据我的实体自动同步并生成数据库。

Once I create Entities I usually run following commands to sync and generate database automatically according to my entities.

./vendor/bin/doctrine-module orm:validate-schema
./vendor/bin/doctrine-module orm:schema-tool:create

有没有办法使此过程反向?我的意思是,我可以从mysql中的现有数据库生成实体吗?

Is there a way to make this process reverse? I mean, Can I generate entities from existing database in mysql?

推荐答案

我们使用批处理脚本:

@ECHO OFF

mkdir EXPORT
call .\vendor\bin\doctrine-module orm:convert-mapping --force --from-database annotation ./EXPORT/
call .\vendor\bin\doctrine-module orm:generate-entities ./EXPORT/ --generate-annotations=true

pause 

orm:convert-mapping orm:generate-entities 可能就是您想要的。

orm:convert-mapping and orm:generate-entities is probably what you are looking for.

这篇关于如何使用doctrine-orm-module和zf2从数据库模式生成实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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