awls99 Posted February 11, 2010 Posted February 11, 2010 This is a ridiculous easy question, I've seen how it's done but I lost it and can't replicate it.... How do I make a module create a couple new DB tables during instalation? Share this post Link to post Share on other sites More sharing options...
Krystian Podemski Posted February 16, 2010 Posted February 16, 2010 For example: function installDB() { return Db::getInstance()->Execute(' CREATE TABLE `'._DB_PREFIX_.'referralprogram` ( `id_referralprogram` INT UNSIGNED NOT NULL AUTO_INCREMENT, `id_sponsor` INT UNSIGNED NOT NULL, `email` VARCHAR(255) NOT NULL, `lastname` VARCHAR(128) NOT NULL, `firstname` VARCHAR(128) NOT NULL, `id_customer` INT UNSIGNED DEFAULT NULL, `id_discount` INT UNSIGNED DEFAULT NULL, `id_discount_sponsor` INT UNSIGNED DEFAULT NULL, `date_add` DATETIME NOT NULL, `date_upd` DATETIME NOT NULL, PRIMARY KEY (`id_referralprogram`), UNIQUE KEY `index_unique_referralprogram_email` (`email`) ) DEFAULT CHARSET=utf8 ;'); } public function install() { $langs = Language::getLanguages(false); foreach ($langs AS $lang) $desc[$lang['id_lang']] = 'ReferralProgram'; if (!parent::install() OR !$this->installDB() OR !Configuration::updateValue('REFERRAL_DISCOUNT_DESCRIPTION', $desc) OR !Configuration::updateValue('REFERRAL_ORDER_QUANTITY', 1) OR !Configuration::updateValue('REFERRAL_DISCOUNT_VALUE', 5) OR !Configuration::updateValue('REFERRAL_DISCOUNT_TYPE', 2) OR !Configuration::updateValue('REFERRAL_NB_FRIENDS', 5) OR !$this->registerHook('shoppingCart') OR !$this->registerHook('orderConfirmation') OR !$this->registerHook('updateOrderStatus') OR !$this->registerHook('adminCustomers') OR !$this->registerHook('createAccount') OR !$this->registerHook('createAccountForm') OR !$this->registerHook('customerAccount') ) return false; /* This hook is optional */ $this->registerHook('myAccountBlock'); return true; } Check this code. Share this post Link to post Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now