execute( 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'ws_customhtml_slide_lang` ( `id_ws_customhtml_slide` INT(11) NOT NULL, `id_lang` INT(11) NOT NULL, `title` VARCHAR(256) NOT NULL DEFAULT \'\', `description` TEXT, `extra_description` TEXT, `link` VARCHAR(512) NOT NULL DEFAULT \'\', `link_text` VARCHAR(128) NOT NULL DEFAULT \'\', PRIMARY KEY (`id_ws_customhtml_slide`, `id_lang`) );' ); } function migrateSlideFieldsToLangTable(): bool { $columns = Db::getInstance()->executeS( 'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml_slide` LIKE \'title\'' ); if (empty($columns)) { // Already migrated in a previous run of this upgrade. return true; } $slides = Db::getInstance()->executeS( 'SELECT `id_ws_customhtml_slide`, `title`, `description`, `extra_description`, `link`, `link_text` FROM `' . _DB_PREFIX_ . 'ws_customhtml_slide`' ); $languages = Language::getLanguages(false); foreach ($slides as $slide) { foreach ($languages as $language) { $existing = Db::getInstance()->executeS( 'SELECT 1 FROM `' . _DB_PREFIX_ . 'ws_customhtml_slide_lang` WHERE `id_ws_customhtml_slide` = ' . (int) $slide['id_ws_customhtml_slide'] . ' AND `id_lang` = ' . (int) $language['id_lang'] ); if (!empty($existing)) { continue; } $result = Db::getInstance()->insert('ws_customhtml_slide_lang', [ 'id_ws_customhtml_slide' => (int) $slide['id_ws_customhtml_slide'], 'id_lang' => (int) $language['id_lang'], 'title' => pSQL($slide['title']), 'description' => pSQL($slide['description']), 'extra_description' => pSQL($slide['extra_description']), 'link' => pSQL($slide['link']), 'link_text' => pSQL($slide['link_text']), ]); if (!$result) { return false; } } } return true; } function dropSlideLangColumns(): bool { $columns = Db::getInstance()->executeS( 'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml_slide` LIKE \'title\'' ); if (empty($columns)) { return true; } return Db::getInstance()->execute( 'ALTER TABLE `' . _DB_PREFIX_ . 'ws_customhtml_slide` DROP COLUMN `title`, DROP COLUMN `description`, DROP COLUMN `extra_description`, DROP COLUMN `link`, DROP COLUMN `link_text`' ); }