今天拷站架Magento 站,又碰到了这种错:
a:4:{i:0;s:116:"Notice: Undefined index : 0 in ***\app\code\core\Mage\Core\Model\Mysql4\Config.php on line 92 ";i:1;s:681:"#0 ***\app\code\core\Mage\Core\Model\Mysql4\Config.php(92): mageCoreErrorHandler(8, 'Undefined index...', 'D:\chen\www\mym...', 92, Array)
#1 ***\app\code\core\Mage\Core\Model\Config.php(344): Mage_Core_Model_Mysql4_Config->loadToXml(Object(Mage_Core_Model_Config))
好吧,抽时间总结一下。。
问题原因 :
Mysql使用工具 (如PhpMyAdmin / MySQL-Front / Navicat for MySQL / SQLyogEnt等)重载转储文件(也就是重导.sql文件)的时候,默认在执行过程中遇到0值一般会生成新的序列号。
Magento的core_store表的admin的store_id为0;core_store_group表的Default的group_id也为0。
在导入.sql文件的时候,原本的0变成了新的序列号,破坏了Magento原有的数据。
解决办法 :
1,
执行一遍下面语句。
SET FOREIGN_KEY_CHECKS=0;
update `core_store` set store_id = 0 where code='admin';
update `core_store_group` set group_id = 0 where name='Default';
update `core_website` set website_id = 0 where code='admin';
update `customer_group` set customer_group_id = 0 where customer_group_code='NOT LOGGED IN';
SET FOREIGN_KEY_CHECKS=1;
2,
在导的.sql文件最前面加入:SET SQL_MODE = NO_AUTO_VALUE_ON_ZERO;
补充,
Mysql的模式:NO_AUTO_VALUE_ON_ZERO
这个项影响 AUTO_INCREMENT 列的处理。
正常情况下,当我们向 AUTO_INCREMENT 列插入0或NULL的时候,会产生下一个序列号。
而mode = NO_AUTO_VALUE_ON_ZERO的时候,只有NULL才产生新的序列号,屏蔽了0。
如此,像遇到Magento报错 - Notice: Undefined index : \app\code\core\Mage\Core\Model\Mysql4\Config.php on line 92 这种问题就解决了。
--EOF--
没明白啊
评分:4分
卢松松 : 2010-12-14 11:30
没明白啊
男士护肤品 : 2010-12-13 20:46
不知道怎么回事 可能...我也不太清楚