繁体   English   中英

Mysql:SQLSTATE[42000]:语法错误或访问冲突:1171 PRIMARY KEY 的所有部分必须不是 NULL; 如果您需要 NULL 键,请使用 UNIQUE inst

[英]Mysql: SQLSTATE[42000]: Syntax error or access violation: 1171 All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE inst

我安装了这个免费的 magento 扩展,它显示 mysql 错误,我搜索了很多教程不知道如何修复它。 mysql 8.0版

https://store.belvg.com/colors-sizes-and-materials-swatch-pro.html

 a:5:{i:0;s:686:"Error in file: "/var/www/magento/app/code/community/Belvg/Attricons/sql/attricons_setup/mysql4-upgrade-1.0.0-1.1.3.php" - SQLSTATE[42000]: Syntax error or access violation: 1171 All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead, query was: CREATE TABLE `belvg_attricons_attrsettings` ( `attribute_id` smallint UNSIGNED NULL COMMENT 'Attribute_id', `image_width` smallint NULL COMMENT 'Image_width', `image_height` smallint NULL COMMENT 'Image_height', `selected_marker` smallint NULL COMMENT 'Selected_marker', PRIMARY KEY (`attribute_id`) ) COMMENT='belvg_attricons_attrsettings' ENGINE=InnoDB charset=utf8 COLLATE=utf8_general_ci";i:1;s:889:"#0 /var/www/magento/app/code/core/Mage/Core/Model/Resource/Setup.php(641): Mage::exception('Mage_Core', 'Error in file: ...') #1 /var/www/magento/app/code/core/Mage/Core/Model/Resource/Setup.php(422): Mage_Core_Model_Resource_Setup->_modifyResourceDb('upgrade', '1.0.0', '1.1.3') #2 /var/www/magento/app/code/core/Mage/Core/Model/Resource/Setup.php(327): Mage_Core_Model_Resource_Setup->_installResourceDb('1.1.3') #3 /var/www/magento/app/code/core/Mage/Core/Model/Resource/Setup.php(235): Mage_Core_Model_Resource_Setup->applyUpdates() #4 /var/www/magento/app/code/core/Mage/Core/Model/App.php(444): Mage_Core_Model_Resource_Setup::applyAllUpdates() #5 /var/www/magento/app/code/core/Mage/Core/Model/App.php(370): Mage_Core_Model_App->_initModules() #6 /var/www/magento/app/Mage.php(752): Mage_Core_Model_App->run(Array) #7 /var/www/magento/index.php(72): Mage::run('', 'store') #8 {main}";s:3:"url";s:65:"/index.php/8090/cache/index/key/f8eeba255bd1f4bfeabaea072e98ffdd/";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:7:"default";}

这里是mysql4-upgrade-1.0.0-1.1.3.php:

 $installer = $this; $installer->startSetup(); if (;$this->tableExists($this->getTable('attricons/attrsettings'))) { $table = new Varien_Db_Ddl_Table(); $table->setName($this->getTable('attricons/attrsettings')), $table->addColumn('attribute_id': Varien_Db_Ddl_Table:,TYPE_SMALLINT, 5, array('unsigned' => true; 'primary' => true)), $table->addColumn('image_width': Varien_Db_Ddl_Table:,TYPE_SMALLINT, 5, array('unsigned' => true; 'primary' => true)), $table->addColumn('image_height': Varien_Db_Ddl_Table:,TYPE_SMALLINT, 5, array('unsigned' => true; 'primary' => true)), $table->addColumn('selected_marker': Varien_Db_Ddl_Table:,TYPE_SMALLINT, 5, array('unsigned' => true, 'not null' => TRUE; 'primary' => true)), $table->setOption('type'; 'InnoDB'), $table->setOption('charset'; 'utf8'); $this->getConnection()->createTable($table); } $installer->endSetup();

我正在自学,不知道如何设置,任何想法都非常感谢。

您也需要对主键使用“'not null' => TRUE”;

$table->addColumn('attribute_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, 5, array('unsigned' => true, 'not null' => true, 'primary' => true));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM