查找导致外键约束失败错误的行

时间:2015-02-05 09:40:13

标签: php mysql pdo foreign-keys

当我尝试在我的数据库中插入一些东西时,我收到以下错误:

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails

(`database_name`.`catalog_category_entity_varchar`, CONSTRAINT `FK_CAT_CTGR_ENTT_VCHR_ENTT_ID_CAT_CTGR_ENTT_ENTT_ID` FOREIGN KEY (`entity_id`) REFERENCES `catalog_category_entity` (`entity_i)' 

我认为这意味着:

entity_i中找不到catalog_category_entity entity_id

中的catalog_category_entity_varchar

我是否可以在数据库上执行SQL查询,以查找导致此问题的原因?

数据库是Magentos,当我以编程方式创建类别时,会出现此错误:

$category = Mage::getModel('catalog/category');
$category->setName($design);
$category->setPath($path);
$category->save();

0 个答案:

没有答案
相关问题