Symfony2:doctrine:mapping:import throws Doctrine\ORM\Mapping\MappingException - Table [...]没有主键。 [英] Symfony2: doctrine:mapping:import throws Doctrine\ORM\Mapping\MappingException - Table [...] has no primary key.

查看:201
本文介绍了Symfony2:doctrine:mapping:import throws Doctrine\ORM\Mapping\MappingException - Table [...]没有主键。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为名为商店的表导入Doctrine映射。我做:

I want to import a Doctrine mapping for a table called stores. I do:

./app/console doctrine:mapping:import MyBundle annotation --filter="stores" 

我收到错误:

[Doctrine\ORM\Mapping\MappingException]                                                                              
  Table Cat_map has no primary key. Doctrine does not support reverse engineering from tables that don't have a prima  
  ry key. 

我使用过滤器不正确吗?我不想要教学尝试和映射除商店之外的任何表格

Am I using the filter incorrectly? I dont want doctrine to try and map any table other than 'stores'

请求的创建语法:

CREATE TABLE `stores` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `storeid` int(11) NOT NULL,
  `store` text NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=96 DEFAULT CHARSET=utf8;


推荐答案

尽管 - 过滤器如果一切都OK,那么通过过滤器只创建指定的实体。

Despite the --filter attribute Doctrine analyse all the tables. If everything is OK then it go through the filter creating only the specified entity.

所以,你应该尝试修复 cat_map 表添加主键。
如果您没有找到方法,或者如果您有特定需求,请更新您的问题,包括 cat_map 部分。

So, you should try to fix the cat_map table adding a primary key. If you're not figuring out a way or if you got particular needs, please update your question including the cat_map part.

我希望这有帮助!

这篇关于Symfony2:doctrine:mapping:import throws Doctrine\ORM\Mapping\MappingException - Table [...]没有主键。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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