public function reset_data() { $resetall = count($this->steps) == 1 && $this->steps[0] == 'reset_data'; $sql = array(); if (in_array('acepolls_polls', $this->steps) || $resetall) { $sql[] = 'TRUNCATE TABLE #__acepolls_polls;'; $sql[] = 'TRUNCATE TABLE #__acepolls_options;'; $sql[] = 'TRUNCATE TABLE #__acepolls_votes;'; } if (in_array('acepolls_votes', $this->steps) || $resetall) { $sql[] = 'TRUNCATE TABLE #__acepolls_votes;'; } $valid = true; foreach ($sql as $query) { $this->destination_db->setQuery($query); $result = $this->destination_db->query(); if (!$result) { $valid = false; } } if (VMMigrateHelperDatabase::queryBatch($this->destination_db, $sql)) { $this->logInfo(JText::_('DATA_RESETED')); } else { $this->logError(JText::_('DATA_RESET_ERROR')); } }
public function reset_data() { $resetall = count($this->steps) == 1 && $this->steps[0] == 'reset_data'; $sql = ''; if (in_array('vm_vendor', $this->steps) || $resetall) { $sql .= "TRUNCATE TABLE #__virtuemart_vendors;"; $sql .= "TRUNCATE TABLE #__virtuemart_vendors_" . $this->baseLanguageTable . ";"; foreach ($this->additionalLanguages as $language) { $sql .= "TRUNCATE TABLE #__virtuemart_vendors_" . $this->getLanguageTableSuffix($language->lang_code) . ";"; } $sql .= "TRUNCATE TABLE #__virtuemart_vendor_medias;"; } if (in_array('vm_tax_rate', $this->steps) || $resetall) { $sql .= "DELETE FROM #__virtuemart_calcs WHERE calc_kind = 'Tax';"; $sql .= "DELETE FROM #__virtuemart_calc_countries WHERE virtuemart_calc_id NOT IN (SELECT virtuemart_calc_id FROM #__virtuemart_calcs);"; $sql .= "DELETE FROM #__virtuemart_calc_states WHERE virtuemart_calc_id NOT IN (SELECT virtuemart_calc_id FROM #__virtuemart_calcs);"; $sql .= "DELETE FROM #__virtuemart_calc_categories WHERE virtuemart_calc_id NOT IN (SELECT virtuemart_calc_id FROM #__virtuemart_calcs);"; $sql .= "DELETE FROM #__virtuemart_calc_shoppergroups WHERE virtuemart_calc_id NOT IN (SELECT virtuemart_calc_id FROM #__virtuemart_calcs);"; } if (in_array('vm_payment_method', $this->steps) || $resetall) { $sql .= "TRUNCATE TABLE #__virtuemart_paymentmethods;"; $sql .= "TRUNCATE TABLE #__virtuemart_paymentmethods_" . $this->baseLanguageTable . ";"; foreach ($this->additionalLanguages as $language) { $sql .= "TRUNCATE TABLE #__virtuemart_paymentmethods_" . $this->getLanguageTableSuffix($language->lang_code) . ";"; } } if (in_array('vm_shipment_method', $this->steps) || in_array('vm_shipping_rates', $this->steps) || $resetall) { $sql .= "TRUNCATE TABLE #__virtuemart_shipmentmethods;"; $sql .= "TRUNCATE TABLE #__virtuemart_shipmentmethods_" . $this->baseLanguageTable . ";"; foreach ($this->additionalLanguages as $language) { $sql .= "TRUNCATE TABLE #__virtuemart_shipmentmethods_" . $this->getLanguageTableSuffix($language->lang_code) . ";"; } } if (in_array('vm_shopper_group', $this->steps) || $resetall) { $sql .= "DELETE FROM #__virtuemart_shoppergroups WHERE virtuemart_shoppergroup_id > 2;"; $sql .= "DELETE FROM #__virtuemart_calcs WHERE calc_kind = 'DBTaxBill';"; $sql .= "DELETE FROM #__virtuemart_calc_countries WHERE virtuemart_calc_id NOT IN (SELECT virtuemart_calc_id FROM #__virtuemart_calcs);"; $sql .= "DELETE FROM #__virtuemart_calc_states WHERE virtuemart_calc_id NOT IN (SELECT virtuemart_calc_id FROM #__virtuemart_calcs);"; $sql .= "DELETE FROM #__virtuemart_calc_categories WHERE virtuemart_calc_id NOT IN (SELECT virtuemart_calc_id FROM #__virtuemart_calcs);"; $sql .= "DELETE FROM #__virtuemart_calc_shoppergroups WHERE virtuemart_calc_id NOT IN (SELECT virtuemart_calc_id FROM #__virtuemart_calcs);"; } if (in_array('vm_category', $this->steps) || $resetall) { $sql .= "TRUNCATE TABLE #__virtuemart_categories;"; $sql .= "TRUNCATE TABLE #__virtuemart_categories_" . $this->baseLanguageTable . ";"; foreach ($this->additionalLanguages as $language) { $sql .= "TRUNCATE TABLE #__virtuemart_categories_" . $this->getLanguageTableSuffix($language->lang_code) . ";"; } $sql .= "TRUNCATE TABLE #__virtuemart_category_categories;"; $sql .= "TRUNCATE TABLE #__virtuemart_category_medias;"; } if (in_array('vm_manufacturer_category', $this->steps) || $resetall) { $sql .= "TRUNCATE TABLE #__virtuemart_manufacturercategories;"; $sql .= "TRUNCATE TABLE #__virtuemart_manufacturercategories_" . $this->baseLanguageTable . ";"; foreach ($this->additionalLanguages as $language) { $sql .= "TRUNCATE TABLE #__virtuemart_manufacturercategories_" . $this->getLanguageTableSuffix($language->lang_code) . ";"; } } if (in_array('vm_manufacturer', $this->steps) || $resetall) { $sql .= "TRUNCATE TABLE #__virtuemart_manufacturers;"; $sql .= "TRUNCATE TABLE #__virtuemart_manufacturers_" . $this->baseLanguageTable . ";"; foreach ($this->additionalLanguages as $language) { $sql .= "TRUNCATE TABLE #__virtuemart_manufacturers_" . $this->getLanguageTableSuffix($language->lang_code) . ";"; } } if (in_array('vm_order_status', $this->steps) || $resetall) { $sql .= "DELETE FROM #__virtuemart_orderstates WHERE order_status_code NOT IN ('S','R','X','C','U','P');"; } if (in_array('vm_userfield', $this->steps) || $resetall) { $sql .= "DELETE FROM #__virtuemart_userfields WHERE sys = 0;"; $sql .= "DELETE FROM #__virtuemart_userfield_values WHERE virtuemart_userfield_id NOT IN (SELECT virtuemart_userfield_id FROM #__virtuemart_userfields);"; } if (in_array('vm_shopper_vendor_xref', $this->steps) || $resetall) { $sql .= "TRUNCATE TABLE #__virtuemart_userinfos;"; $sql .= "TRUNCATE TABLE #__virtuemart_vmuser_shoppergroups;"; $sql .= "TRUNCATE TABLE #__virtuemart_vmusers;"; } if (in_array('vm_product_type', $this->steps) || $resetall) { $sql .= "DELETE FROM #__virtuemart_customs WHERE field_type NOT IN ('R','Z');"; } if (in_array('vm_product', $this->steps) || $resetall) { $sql .= "TRUNCATE TABLE #__virtuemart_products;"; $sql .= "TRUNCATE TABLE #__virtuemart_products_" . $this->baseLanguageTable . ";"; foreach ($this->additionalLanguages as $language) { $sql .= "TRUNCATE TABLE #__virtuemart_products_" . $this->getLanguageTableSuffix($language->lang_code) . ";"; } $sql .= "TRUNCATE TABLE #__virtuemart_product_categories;"; $sql .= "TRUNCATE TABLE #__virtuemart_product_manufacturers;"; $sql .= "TRUNCATE TABLE #__virtuemart_product_prices;"; } if (in_array('vm_product_type', $this->steps) && in_array('vm_product', $this->steps) || $resetall) { $sql .= "TRUNCATE TABLE #__virtuemart_product_customfields;"; } if (in_array('vm_product_medias', $this->steps) || $resetall) { $sql .= "DELETE FROM #__virtuemart_medias WHERE file_type='product';"; $sql .= "TRUNCATE TABLE #__virtuemart_product_medias;"; } if (in_array('vm_waiting_list', $this->steps) || $resetall) { $sql .= "TRUNCATE TABLE #__virtuemart_waitingusers;"; } //if (in_array('vm_product_votes',$this->steps) || $resetall) { // $sql .= "TRUNCATE TABLE #__virtuemart_rating_votes;"; //} if (in_array('vm_product_reviews', $this->steps) || $resetall) { $sql .= "TRUNCATE TABLE #__virtuemart_rating_reviews;"; $sql .= "TRUNCATE TABLE #__virtuemart_rating_votes;"; $sql .= "TRUNCATE TABLE #__virtuemart_ratings;"; } if (in_array('vm_product_discount', $this->steps) || $resetall) { //$sql .= "TRUNCATE TABLE #__virtuemart_calcs;"; } if (in_array('vm_orders', $this->steps) || $resetall) { $sql .= "TRUNCATE TABLE #__virtuemart_orders;"; $sql .= "TRUNCATE TABLE #__virtuemart_order_histories;"; $sql .= "TRUNCATE TABLE #__virtuemart_order_items;"; $sql .= "TRUNCATE TABLE #__virtuemart_order_userinfos;"; } if (in_array('vm_coupons', $this->steps) || $resetall) { $sql .= "TRUNCATE TABLE #__virtuemart_coupons;"; } if (!$sql) { return; } if (VMMigrateHelperDatabase::queryBatch($this->destination_db, $sql)) { foreach ($this->steps as $step) { $this->logInfo(JText::sprintf('DATA_RESETED', JText::_($step))); } $this->resetAutoIncrements(); } else { $this->logError(JText::_('DATA_RESET_ERROR') . '<br/>' . $this->destination_db->getErrorMsg()); } }
public function reset_data() { $resetall = count($this->steps) == 1 && $this->steps[0] == 'reset_data'; $sql = ''; if (in_array('joom_menu_types', $this->steps) || $resetall) { $sql .= "TRUNCATE TABLE #__menu_types;"; } if (in_array('joom_menus', $this->steps) || $resetall) { $sql .= "DELETE FROM #__menu WHERE client_id = 0 and id<>1;"; } if (in_array('joom_users', $this->steps) || $resetall) { $sql .= "TRUNCATE TABLE #__users;"; $sql .= "TRUNCATE TABLE #__messages_cfg;"; } if (in_array('joom_sections', $this->steps) || $resetall) { $sql .= "DELETE FROM #__categories WHERE `extension` = 'com_content';"; $sql .= "DELETE FROM #__assets WHERE `name` like 'com_content.category%';"; } if (in_array('joom_articles', $this->steps) || $resetall) { $sql .= "TRUNCATE TABLE #__content;"; $sql .= "TRUNCATE TABLE #__content_frontpage;"; $sql .= "DELETE FROM #__assets WHERE `name` like 'com_content.article%';"; } if (in_array('joom_contact_categories', $this->steps) || $resetall) { $sql .= "DELETE FROM #__categories WHERE `extension` = 'com_contact';"; $sql .= "DELETE FROM #__assets WHERE `name` like 'com_contact.category%';"; } if (in_array('joom_contact', $this->steps) || $resetall) { $sql .= "TRUNCATE TABLE #__contact_details;"; } if (in_array('joom_weblinks_categories', $this->steps) || $resetall) { $sql .= "DELETE FROM #__categories WHERE `extension` = 'com_weblinks';"; $sql .= "DELETE FROM #__assets WHERE `name` like 'com_weblinks.category%';"; } if (in_array('joom_weblinks', $this->steps) || $resetall) { $sql .= "TRUNCATE TABLE #__weblinks;"; } if (in_array('joom_newsfeeds_categories', $this->steps) || $resetall) { $sql .= "DELETE FROM #__categories WHERE `extension` = 'com_newsfeeds';"; } if (in_array('joom_newsfeeds', $this->steps) || $resetall) { $sql .= "TRUNCATE TABLE #__newsfeeds;"; } if (in_array('joom_banners_categories', $this->steps) || $resetall) { $sql .= "DELETE FROM #__categories WHERE `extension` = 'com_banners';"; $sql .= "DELETE FROM #__assets WHERE `name` like 'com_banners.category%';"; } if (in_array('joom_banners_clients', $this->steps) || $resetall) { $sql .= "TRUNCATE TABLE #__banner_clients;"; } if (in_array('joom_banners', $this->steps) || $resetall) { $sql .= "TRUNCATE TABLE #__banners;"; $sql .= "TRUNCATE TABLE #__banner_tracks;"; } if (in_array('joom_banners_tracks', $this->steps) || $resetall) { $sql .= "TRUNCATE TABLE #__banner_tracks;"; } if (in_array('joom_search', $this->steps) || $resetall) { $sql .= "TRUNCATE TABLE #__core_log_searches;"; } if (in_array('joom_messages', $this->steps) || $resetall) { $sql .= "TRUNCATE TABLE #__messages;"; } if (in_array('joom_modules', $this->steps) || $resetall) { $sql .= "DELETE FROM #__modules WHERE client_id = 0;"; $sql .= "DELETE FROM #__modules_menu WHERE moduleid NOT IN (SELECT id from #__modules);"; } if (in_array('joom_images', $this->steps) || $resetall) { $sql .= "TRUNCATE TABLE #__vmmigrate_temp"; } if (!$sql) { return; } if (VMMigrateHelperDatabase::queryBatch($this->destination_db, $sql)) { foreach ($this->steps as $step) { $this->logInfo(JText::sprintf('DATA_RESETED', JText::_($step))); } $this->resetAutoIncrements(); } else { $this->logError(JText::_('DATA_RESET_ERROR') . '<br/>' . $this->destination_db->getErrorMsg()); } }