gpt4 book ai didi

mysql - Magento 客户实体表删除表属性中的 UNIQUE KEY

转载 作者:行者123 更新时间:2023-12-01 00:40:34 24 4
gpt4 key购买 nike

我需要用我的插件设置脚本更改 magento 中的默认 customer_entity 表描述,是否可以让它删除 UNIQUE KEY 字段?

magento customer_entity 表结构描述为:

CREATE TABLE `customer_entity` (
`entity_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Entity Id',
`entity_type_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Entity Type Id',
`attribute_set_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Attribute Set Id',
`website_id` smallint(5) unsigned DEFAULT NULL COMMENT 'Website Id',
`email` varchar(255) DEFAULT NULL COMMENT 'Email',
...
UNIQUE KEY `UNQ_CUSTOMER_ENTITY_EMAIL_WEBSITE_ID` (`email`,`website_id`),
...

所以我需要的是用安装脚本让它删除这个

UNIQUE KEY `UNQ_CUSTOMER_ENTITY_EMAIL_WEBSITE_ID` (`email`,`website_id`)

最佳答案

您可以在更新/安装脚本中运行 sql 查询:

<?php
$installer = $this;
$installer->startSetup();
$sql= 'ALTER TABLE `customer_entity` DROP INDEX `UNQ_CUSTOMER_ENTITY_EMAIL_WEBSITE_ID`'
$installer->run($sql);
$installer->endSetup();

或者您可以像这样以“magento 方式”进行操作(未经测试的代码!)

<?php
$installer = $this;
$installer->getConnection()->dropKey('customer_entity', 'UNQ_CUSTOMER_ENTITY_EMAIL_WEBSITE_ID')
$installer->endSetup();

关于mysql - Magento 客户实体表删除表属性中的 UNIQUE KEY,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33525712/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com