duanliang1019 2011-07-28 19:48
浏览 62
已采纳

Doctrine 2和Zend 1.11转换映射错误..

I have a complex database design with views, relationship etc. We decided to switch to ORM from the standard Zend_db. I successfully integrated zend 1.11 and doctrine 2.1. All the tutorials out there explains about creating the entire database through hand written classes. But what about already existing database with data in it? I again searched and found out that I got to use the below command

php orm:convert-mapping --from-database php path/where/you/want/to/store/mapping/classes

When I do it for a simple database with only 3 tables and without any relationship, the above command works beautifully.

But when I tried to use the same command on my database it throws a exception saying

[Doctrine\ORM\Mapping\MappingException]

Property "employeeid" in "Organization_has_employees" was already declared, but it must be
declared only once

I changed all my field name so that there is no repeated names in any of the table but still no luck.

Please help me with this. I am breaking my head for more than 3 days.

Karthik

  • 写回答

1条回答 默认 最新

  • douweidao3882 2011-07-28 21:08
    关注

    After hours of experiment I found out the problem. Obviously it is not in Doctrine it is the database that I designed. When you do Many-To-Many tables in MySQL Workbenck you are forced to do Identifying Relationship, which create another table and create composite keys from the parent tables. Please make sure that you name this primary keys differently or if possible remove composit keys and have it as just a Non-identifying relationship. Add another column called id and have this field as a primary key and auto-numbering

    Doctrine tool has a caching problem as well so please make sure that you rename the database everytime you make a change and change it in your zend config.

    Hope this helps someone out there. If you still have problems please post your questions here I will be able to answer it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值