zf2 用学说 ORM 生成实体 [英] zf2 generating entity with doctrine ORM

查看:14
本文介绍了zf2 用学说 ORM 生成实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有使用 Doctrine ORM 和 ZF2 生成的实体类.

I have Entity classes generated with Doctrine ORM, and ZF2.

我改变了一个表结构,我想更新一个实体类,所以我试图重新生成实体类,但它不起作用.

I changed a table structure and I want to update an entity class, so I am trying to regenerate the entity class but it's not working.

我使用了以下代码:

vendor/doctrine/doctrine-module/bin/doctrine-module orm:convert-mapping --namespace="Album\Entity\" --force --from-database 注释 ./module/Album/src/clear

vendor/doctrine/doctrine-module/bin/doctrine-module orm:convert-mapping --namespace="Album\Entity\" --force --from-database annotation ./module/Album/src/clear

我收到错误:

[Doctrine\ORM\Mapping\MappingException]
Album\Entity\TestRun"中的属性status"已经声明,但只能声明一次
orm:convert-mapping [--filter="..."] [--force] [--from-database] [--extend[="..."]] [--num-spaces[="..."]] [--namespace[="..."]] to-type dest-path

[Doctrine\ORM\Mapping\MappingException]
Property "status" in "Album\Entity\TestRun" was already declared, but it must be declared only once
orm:convert-mapping [--filter="..."] [--force] [--from-database] [--extend[="..."]] [--num-spaces[="..."]] [--namespace[="..."]] to-type dest-path

我想为特定表重新生成实体类

I want to re-generate the entity class for a particular table

推荐答案

如上所述,这可能是一个不好的做法,但我仍然使用以下命令来实现您所询问的结果:

As mentioned above it might be a bad practice, but nevertheless I use the following commands to achieve the result you are asking about:

vendor\bin\doctrine-module orm:convert-mapping --filter='Evaluation' --namespace='MyModule\Entity\\' --force --from-database annotation ./module/MyModule/src/   

和另一个生成 getter 和 setter 的命令:

and another command to generate getters and setters:

vendor\bin\doctrine-module orm:generate-entities --filter='Evaluation' ./module/MyModule/src/ --generate-annotations=true

这篇关于zf2 用学说 ORM 生成实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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