如何在 Prestashop 模块上安装数据库?
How to reinstall database on Prestahop Module?
我正在尝试自定义 Prestashop 模块,我需要在 table 中添加两个新的冒号。
问题是数据库已经创建了,我猜是在模块初始化的时候创建的。因此,如果我现在更改代码,则不会出现更改,并且我一直收到此错误:
无法在配置中执行此操作,我想如果我删除该模块,我的代码将消失。
我该怎么办?
也许在一个普通方法中询问删除和创建方法(一次)。
我是 Smarty 和 PHP 的新手,我发现这不是创建 table 的常用方法。
你能帮帮我吗?
我是 Smarty 的新手,我该怎么做?
看起来这不是创建 table 的方法。
$sql = array();
$sql[] =
'CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'opartdevis` (
`id_opartdevis` int(10) NOT NULL AUTO_INCREMENT,
`id_shop` int(10) NOT NULL,
`id_cart` int(10) NOT NULL,
`id_customer` int(10) NOT NULL,
`name` varchar(128),
`message_visible` TEXT,
`id_customer_thread` int(10),
`date_add` DATETIME NOT NULL,
`status` int(2) DEFAULT 0,
`id_order` int(10) NULL,
`id_ordered_cart` int(10) NULL,
`remise` int(10),
`delivery` int(10),
PRIMARY KEY (`id_opartdevis`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8';
//1.6.1.0 specific price bug fix
if (version_compare(_PS_VERSION_, '1.6.1.0', '=')) {
$sql[] = "ALTER TABLE "._DB_PREFIX_."specific_price DROP INDEX id_product_2";
$sql[] = "ALTER TABLE "._DB_PREFIX_."specific_price ADD INDEX id_product_2 (id_product,id_shop,id_shop_group,id_currency,id_country,id_group,id_customer,id_product_attribute,from_quantity,id_specific_price_rule,id_cart,`from`,`to`)";
}
foreach ($sql as $s) {
if (!Db::getInstance()->execute($s)) {
return false;
}
}
提前致谢
身体不适
卸载模块时需要还原所有数据库更改。
在基本模块文件中定义(或附加到现有的)uninstall()
函数,并在创建的 table 上 运行 DROP TABLE
查询。示例:
public function uninstall() {
if (!parent::uninstall()) {
return false;
}
$sql = 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'opartdevis`';
if (!Db::getInstance()->execute($sql)) {
return false;
}
return true;
}
这样,当您卸载模块时,table 将被删除(并在您再次安装时重新创建)。
我正在尝试自定义 Prestashop 模块,我需要在 table 中添加两个新的冒号。
问题是数据库已经创建了,我猜是在模块初始化的时候创建的。因此,如果我现在更改代码,则不会出现更改,并且我一直收到此错误:
无法在配置中执行此操作,我想如果我删除该模块,我的代码将消失。
我该怎么办?
也许在一个普通方法中询问删除和创建方法(一次)。
我是 Smarty 和 PHP 的新手,我发现这不是创建 table 的常用方法。
你能帮帮我吗?
我是 Smarty 的新手,我该怎么做? 看起来这不是创建 table 的方法。
$sql = array();
$sql[] =
'CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'opartdevis` (
`id_opartdevis` int(10) NOT NULL AUTO_INCREMENT,
`id_shop` int(10) NOT NULL,
`id_cart` int(10) NOT NULL,
`id_customer` int(10) NOT NULL,
`name` varchar(128),
`message_visible` TEXT,
`id_customer_thread` int(10),
`date_add` DATETIME NOT NULL,
`status` int(2) DEFAULT 0,
`id_order` int(10) NULL,
`id_ordered_cart` int(10) NULL,
`remise` int(10),
`delivery` int(10),
PRIMARY KEY (`id_opartdevis`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8';
//1.6.1.0 specific price bug fix
if (version_compare(_PS_VERSION_, '1.6.1.0', '=')) {
$sql[] = "ALTER TABLE "._DB_PREFIX_."specific_price DROP INDEX id_product_2";
$sql[] = "ALTER TABLE "._DB_PREFIX_."specific_price ADD INDEX id_product_2 (id_product,id_shop,id_shop_group,id_currency,id_country,id_group,id_customer,id_product_attribute,from_quantity,id_specific_price_rule,id_cart,`from`,`to`)";
}
foreach ($sql as $s) {
if (!Db::getInstance()->execute($s)) {
return false;
}
}
提前致谢
身体不适
卸载模块时需要还原所有数据库更改。
在基本模块文件中定义(或附加到现有的)uninstall()
函数,并在创建的 table 上 运行 DROP TABLE
查询。示例:
public function uninstall() {
if (!parent::uninstall()) {
return false;
}
$sql = 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'opartdevis`';
if (!Db::getInstance()->execute($sql)) {
return false;
}
return true;
}
这样,当您卸载模块时,table 将被删除(并在您再次安装时重新创建)。