1
我爲prestashop製作了模塊。只需將基本管理形式寫入DB即可。但是,當我嘗試的Prestashop安裝模塊,我有這個錯誤:安裝Prestashop模塊時出現MySQL錯誤
[PrestaShopDatabaseException]
Duplicate entry '0' for key 'PRIMARY'
INSERT INTO `ps_module` (`name`, `active`, `version`) VALUES ('apishippingtextsource', '1', '0.0.1')
at line 635 in file classes/db/Db.php
629. WebserviceRequest::getInstance()->setError(500, '[SQL Error] '.$this->getMsgError().'. From '.(isset($dbg[3]['class']) ? $dbg[3]['class'] : '').'->'.$dbg[3]['function'].'() Query was : '.$sql, 97);
630. }
631. else if (_PS_DEBUG_SQL_ && $errno && !defined('PS_INSTALLATION_IN_PROGRESS'))
632. {
633. if ($sql)
634. throw new PrestaShopDatabaseException($this->getMsgError().'<br /><br /><pre>'.$sql.'</pre>');
635. throw new PrestaShopDatabaseException($this->getMsgError());
636. }
637. }
638.
639. /**
我install.php了對SQL:
$sql = array();
$sql[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'api_shipping_text` (
`id_text` int(10) unsigned NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id_text`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8;';
foreach ($sql as $query) {
if (Db::getInstance()->execute($query) == false) {
return false;
}
}
的Prestashop的版本是1.6.0.9。
你可以檢查'ps_module'表結構的'auto_increment'值嗎?也許'auto_increment'沒有被定義或定義爲'0' –
@FlorianLemaitre非常感謝,我是白癡。我不設置id列的auto_increment。這裏是我的概率,它是如何可能的,有模塊被安裝。 :d –