当我尝试在我的数据库中插入一些东西时,我收到以下错误:
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();