/** * Make sure the #__akeeba_common table exists or create it from scratch * * @return $this */ public function checkAndFixCommonTables() { // Install or update database $dbInstaller = new F0FDatabaseInstaller(array('dbinstaller_directory' => JPATH_ADMINISTRATOR . '/components/com_akeeba/sql/common')); $dbInstaller->updateSchema(); return $this; }
protected function onBeforeBrowse() { $db = JFactory::getDbo(); $config = J2Store::config(); $installation_complete = $config->get('installation_complete', 0); if (!$installation_complete) { //installation not completed JFactory::getApplication()->redirect('index.php?option=com_j2store&view=postconfig'); } //first check if the currency table has a default records at least. $rows = F0FModel::getTmpInstance('Currencies', 'J2StoreModel')->enabled(1)->getList(); if (count($rows) < 1) { //no records found. Dumb default data F0FModel::getTmpInstance('Currencies', 'J2StoreModel')->create_currency_by_code('USD', 'USD'); } //update schema $dbInstaller = new F0FDatabaseInstaller(array('dbinstaller_directory' => JPATH_ADMINISTRATOR . '/components/com_j2store/sql/xml')); $dbInstaller->updateSchema(); //update cart table $cols = $db->getTableColumns('#__j2store_carts'); $cols_to_delete = array('product_id', 'vendor_id', 'variant_id', 'product_type', 'product_options', 'product_qty'); foreach ($cols_to_delete as $key) { if (array_key_exists($key, $cols)) { $db->setQuery('ALTER TABLE #__j2store_carts DROP COLUMN ' . $key); try { $db->execute(); } catch (Exception $e) { echo $e->getMessage(); } } } return parent::onBeforeBrowse(); }
/** * Runs on uninstallation * * @param JInstaller $parent The parent object */ public function uninstall($parent) { // Uninstall database $dbInstaller = new F0FDatabaseInstaller(array('dbinstaller_directory' => ($this->schemaXmlPathRelative ? JPATH_ADMINISTRATOR . '/components/' . $this->componentName : '') . '/' . $this->schemaXmlPath)); $dbInstaller->removeSchema(); // Uninstall modules and plugins $status = $this->uninstallSubextensions($parent); // Uninstall post-installation messages on Joomla! 3.2 and later $this->uninstallPostInstallationMessages(); // Show the post-uninstallation page $this->renderPostUninstallation($status, $parent); }
/** * Checks the database for missing / outdated tables using the $dbChecks * data and runs the appropriate SQL scripts if necessary. * * @return AdmintoolsModelCpanels */ public function checkAndFixDatabase() { // Install or update database $dbInstaller = new F0FDatabaseInstaller(array('dbinstaller_directory' => JPATH_ADMINISTRATOR . '/components/com_admintools/sql/xml')); $dbInstaller->updateSchema(); // Let's check and fix common tables, too F0FModel::getTmpInstance('Stats', 'AdmintoolsModel')->checkAndFixCommonTables(); return $this; }