0

我有以下 MySQL 安装 SQL 文件。我要做的是修改,以便不再将安装 ID 称为 31,而是在脚本尝试运行时设置一个值。任何人都可以帮忙吗?

# Install Easy Populate Configuration for zen cart v1.5
INSERT INTO admin_pages VALUES ('easyPopulate', 'BOX_TOOLS_EASY_POPULATE', 'FILENAME_EASYPOPULATE', '', 'tools', 'Y', '14');
INSERT INTO admin_pages_to_profiles VALUES ('1', 'easyPopulate');
INSERT INTO admin_pages VALUES ('easyPopulateConfig', 'BOX_CONFIGURATION_EASY_POPULATE', 'FILENAME_CONFIGURATION', 'gID=31', 'configuration', 'Y', '26');
INSERT INTO configuration_group VALUES ('', 'Easy Populate', 'Config options for Easy Populate', '31', '1');
INSERT INTO configuration VALUES
('', 'Uploads Directory', 'EASYPOPULATE_CONFIG_TEMP_DIR', 'tempEP/', 'Name of directory for your uploads (default: tempEP/).', '31', '0', NULL, now(), NULL, NULL),
('', 'Upload File Date Format', 'EASYPOPULATE_CONFIG_FILE_DATE_FORMAT', 'm-d-y', 'Choose order of date values that corresponds to your uploads file, usually generated by MS Excel. Raw dates in your uploads file (Eg 2005-09-26 09:00:00) are not affected, and will upload as they are.', '31', '1', NULL, now(), NULL, 'zen_cfg_select_option(array("m-d-y", "d-m-y", "y-m-d"),'),
('', 'Default Raw Time', 'EASYPOPULATE_CONFIG_DEFAULT_RAW_TIME', '09:00:00', 'If no time value stipulated in upload file, use this value. Useful for ensuring specials begin after a specific time of the day (default: 09:00:00)', '31', '2', NULL, now(), NULL, NULL),
('', 'Split File On # Records', 'EASYPOPULATE_CONFIG_SPLIT_MAX', '300', 'Default number of records for split-file uploads. Used to avoid timeouts on large uploads (default: 300).', '31', '3', NULL, now(), NULL, NULL),
('', 'Maximum Category Depth', 'EASYPOPULATE_CONFIG_MAX_CATEGORY_LEVELS', '7', 'Maximum depth of categories required for your store. Is the number of category columns in downloaded file (default: 7).', '31', '4', NULL, now(), NULL, NULL),
('', 'Upload/Download Prices Include Tax', 'EASYPOPULATE_CONFIG_PRICE_INC_TAX', 'false', 'Choose to include or exclude tax, depending on how you manage prices outside of Zen Cart.', '31', '5', NULL, now(), NULL, 'zen_cfg_select_option(array("true", "false"),'),
('', 'Make Zero Qty Products Inactive', 'EASYPOPULATE_CONFIG_ZERO_QTY_INACTIVE', 'false', 'When uploading, make the status Inactive for products with zero qty (default: false).', '31', '6', NULL, now(), NULL, 'zen_cfg_select_option(array("true", "false"),'),
('', 'Smart Tags Replacement of Newlines', 'EASYPOPULATE_CONFIG_SMART_TAGS', 'true', 'Allows your description fields in your uploads file to have carriage returns and/or new-lines converted to HTML line-breaks on uploading, thus preserving some rudimentary formatting (default: true).', '31', '7', NULL, now(), NULL, 'zen_cfg_select_option(array("true", "false"),'),
('', 'Advanced Smart Tags', 'EASYPOPULATE_CONFIG_ADV_SMART_TAGS', 'false', 'Allow the use of complex regular expressions to format descriptions, making headings bold, add bullets, etc. Configuration is in ADMIN/easypopulate.php (default: false).', '31', '8', NULL, now(), NULL, 'zen_cfg_select_option(array("true", "false"),'),
('', 'Debug Logging', 'EASYPOPULATE_CONFIG_DEBUG_LOGGING', 'true', 'Allow Easy Populate to generate an error log on errors only (default: true)', '31', '9', NULL, now(), NULL, 'zen_cfg_select_option(array("true", "false"),'),
('', 'Custom Products Fields', 'EASYPOPULATE_CONFIG_CUSTOM_FIELDS', '', 'Enter a comma seperated list of fields to be automatically added to import/export file(ie: products_length, products_width). Please make sure field exists in PRODUCTS table.', '31' , '10', NULL, now(), NULL, NULL);

附加信息:(对不起,我忘记了……)

有没有办法做到这一点,这样我就不必使用 ID 31?31 应该代表从命令自动生成的 ID INSERT INTO configuration_group VALUES ('', 'Easy Populate', 'Config options for Easy Populate', '31', '1');.

4

1 回答 1

1

正如您所评论的 - 使用 SET:

SET @installId = '31';

然后使用@installId而不是'31':

INSERT INTO configuration_group VALUES ('', 'Easy Populate', 'Config options for Easy Populate', @installId, '1');

更新

如果 id 是上一个 INSERT 语句中最后一个自动递增的字段,那么您可以使用该LAST_INSERT_ID()函数来检索它:

INSERT INTO configuration_group VALUES ('', 'Easy Populate', 'Config options for Easy Populate', NULL, '1');
SET @autoId = LAST_INSERT_ID();

然后,您可以使用该@autoId变量代替上面的“31”。

于 2012-10-10T18:19:13.787 回答