Jump to content

Query in install - basic question


awls99

Recommended Posts

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.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...