从Doctrine实体创建/更新模式 [英] Creating/updating schema from Doctrine entities

查看:117
本文介绍了从Doctrine实体创建/更新模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Zend框架中使用了Doctrine。我必须使用注释创建DB模式和Doctrine实体。



由于注释已经包含信息,因此应该可以基于他们。我不想重新发明,所以我想知道这种逻辑是否已经存在?

解决方案

你可以使用这个教条CLI,对于很多学说相关的任务。我不知道如何将教义整合到Zend中,但是寻找doctrine.php,并且这样调用:

  php doctrine.php orm:schema-tool:update --force 

这将更新您的数据库以匹配您的模式定义。您还可以使用

  php doctrine.php orm:schema-tool:update --dump-sql 

查看什么SQL命令将会运行原理。请参阅工具部分该教义将会提供更多信息。


I'm using Doctrine with Zend Framework. I have to create both the DB schema and the Doctrine entities with annotations.

Since the annotations already contain the information, it should be possible to create/update the schema based on them. I don't want to reinvent the wheel, so I was wondering whether that kind of logic already existed?

解决方案

You can use the doctrine CLI, for a lot of doctrine related tasks. I'm not sure how doctrine is integrated into Zend, but look for the doctrine.php, and invoke it like this:

php doctrine.php orm:schema-tool:update --force

This will update your db to match your schema definitions. You can also use

php doctrine.php orm:schema-tool:update --dump-sql

To see what SQL commands would doctrine run. See the Tools section in the doctrine docs for more information.

这篇关于从Doctrine实体创建/更新模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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