vr-shopxo-plugin/shopxo/app/plugins/vr_ticket/Event.php

32 lines
1.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
namespace app\plugins\vr_ticket;
class Event
{
public function Install($params = [])
{
$db = \think\facade\Db::connect();
$prefix = \think\facade\Config::get('database.connections.mysql.prefix');
// 给 ShopXO 商品表追加 item_type 字段MySQL 5.x 兼容写法)
$query = $db->query("SHOW COLUMNS FROM `{$prefix}goods` LIKE 'item_type'");
if (count($query) == 0) {
$db->execute("ALTER TABLE `{$prefix}goods` ADD COLUMN `item_type` VARCHAR(20) NOT NULL DEFAULT 'normal' COMMENT '商品类型normal=普通 goods ticket=票务 physical=周边' AFTER `is_shelves`");
}
$queryConfig = $db->query("SHOW COLUMNS FROM `{$prefix}goods` LIKE 'vr_goods_config'");
if (count($queryConfig) == 0) {
$db->execute("ALTER TABLE `{$prefix}goods` ADD COLUMN `vr_goods_config` LONGTEXT COMMENT '票务配置' AFTER `item_type`");
}
}
public function Uninstall($params = [])
{
// 卸载操作通常由 uninstall.sql 完成
}
public function Upgrade($params = [])
{
}
}
?>