function addFPLinksToCategory($category_id, $fp_ids) { global $application; loadCoreFile('db_multiple_insert.php'); $so = $this->__getMaxFPSortOrderForCategory($category_id); $query = new DB_Multiple_Insert('fp_links'); $query->setInsertFields(array('category_id', 'fp_id', 'sort_order')); foreach ($fp_ids as $fp_id) { $i_arr = array('category_id' => $category_id, 'fp_id' => $fp_id, 'sort_order' => ++$so); $query->addInsertValuesArray($i_arr); } $application->db->PrepareSQL($query); return $application->db->DB_Exec(); }
function addRPLinksToProduct($product_id, $rp_ids) { global $application; loadCoreFile('db_multiple_insert.php'); $tables = $this->getTables(); $rp_table = $tables['rp_links']['columns']; $so = $this->__getMaxRPSortOrderForProduct($product_id); $query = new DB_Multiple_Insert('rp_links'); $query->setInsertFields(array('product_id', 'rp_id', 'sort_order')); foreach ($rp_ids as $rp_id) { $i_arr = array('product_id' => $product_id, 'rp_id' => $rp_id, 'sort_order' => ++$so); $query->addInsertValuesArray($i_arr); } $application->db->PrepareSQL($query); return $application->db->DB_Exec(); }
function update_pm_sm_currency_settings($module_id, $module_settings) { global $application; loadCoreFile('db_multiple_insert.php'); //The list of modules,which should become selected. $tables = Checkout::getTables(); // pm_sm_accepted_currencies // pm_sm_currency_acceptance_rules. $cpsac = $tables['checkout_pm_sm_accepted_currencies']['columns']; $query = new DB_Delete('checkout_pm_sm_accepted_currencies'); $query->WhereValue($cpsac['module_id'], DB_EQ, $module_id); $application->db->getDB_Result($query); $cpscar = $tables['checkout_pm_sm_currency_acceptance_rules']['columns']; $query = new DB_Delete('checkout_pm_sm_currency_acceptance_rules'); $query->WhereValue($cpscar['module_id'], DB_EQ, $module_id); $application->db->getDB_Result($query); // ( ) pm_sm_accepted_currencies // pm_sm_currency_acceptance_rules. if (sizeof($module_settings["accepted_currencies"]) > 0) { $query = new DB_Multiple_Insert('checkout_pm_sm_accepted_currencies'); $query->setInsertFields(array($cpsac['module_id'], $cpsac['currency_code'], $cpsac['currency_status'])); foreach ($module_settings["accepted_currencies"] as $info) { $row = array($cpsac['module_id'] => $module_id, $cpsac['currency_code'] => $info['currency_code'], $cpsac['currency_status'] => $info['currency_status']); $query->addInsertValuesArray($row); } $application->db->PrepareSQL($query); $application->db->DB_Exec(); } if (sizeof($module_settings["currency_acceptance_rules"]) > 0) { $query = new DB_Multiple_Insert('checkout_pm_sm_currency_acceptance_rules'); $query->setInsertFields(array($cpscar['module_id'], $cpscar['rule_name'], $cpscar['rule_selected'])); foreach ($module_settings["currency_acceptance_rules"] as $info) { $row = array($cpscar['module_id'] => $module_id, $cpscar['rule_name'] => $info['rule_name'], $cpscar['rule_selected'] => $info['rule_selected']); $query->addInsertValuesArray($row); } $application->db->PrepareSQL($query); $application->db->DB_Exec(); } }
function __saveRateToCache($from, $to, $rate) { $rev_rate = 1 / $rate; global $application; $tables = $this->getTables(); $rc_table = $tables['cconv_rates_cache']['columns']; $query = new DB_Delete('cconv_rates_cache'); $query->addWhereOpenSection(); $query->WhereValue($rc_table['from'], DB_EQ, $from); $query->WhereAnd(); $query->WhereValue($rc_table['to'], DB_EQ, $to); $query->addWhereCloseSection(); $query->WhereOR(); $query->addWhereOpenSection(); $query->WhereValue($rc_table['from'], DB_EQ, $to); $query->WhereAND(); $query->WhereValue($rc_table['to'], DB_EQ, $from); $query->addWhereCloseSection(); $query->WhereOR(); $query->Where($rc_table['expire'], DB_LT, time()); $application->db->getDB_Result($query); loadCoreFile('db_multiple_insert.php'); $query = new DB_Multiple_Insert('cconv_rates_cache'); $query->setInsertFields(array($rc_table['rate'], $rc_table['from'], $rc_table['to'], $rc_table['expire'])); $query->addInsertValuesArray(array($rc_table['from'] => $from, $rc_table['to'] => $to, $rc_table['rate'] => $rate, $rc_table['expire'] => time() + CURRENCY_CONVERTER_RATE_EXPIRE_PERIOD)); $query->addInsertValuesArray(array($rc_table['from'] => $to, $rc_table['to'] => $from, $rc_table['rate'] => $rev_rate, $rc_table['expire'] => time() + CURRENCY_CONVERTER_RATE_EXPIRE_PERIOD)); $application->db->PrepareSQL($query); $application->db->DB_Exec(); return; }
function MULTIPLE_INSERT_BESTSELLERS_LINKS_TO_CATEGORY() { parent::DB_Multiple_Insert('bs_links'); }
function setLetterTopics($letter_id, $topics_ids) { global $application; if (!is_array($topics_ids)) { $topics_ids = array($topics_ids); } $tables = $this->getTables(); $ntables = modApiFunc('Newsletter', 'getTables'); $ltable = 'newsletter_topics'; $lcolumns =& $ntables[$ltable]['columns']; $dquery = new DB_Delete($ltable); $dquery->WhereValue($lcolumns['letter_id'], DB_EQ, $letter_id); $application->db->getDB_Result($dquery); $iquery = new DB_Multiple_Insert($ltable); $iquery->setModifiers(DB_IGNORE); $iquery->setInsertFields(array('letter_id', 'topic_id')); foreach ($topics_ids as $topic_id) { $iquery->addInsertValuesArray(array('letter_id' => $letter_id, 'topic_id' => $topic_id)); } $application->db->getDB_Result($iquery); }
function addLabelsArrayToDB($data, $prefix) { global $application; if (empty($data)) { return false; } loadCoreFile('db_multiple_insert.php'); $tables = Resources::getTables(); $table = "resource_labels"; $columns = $tables[$table]['columns']; $fields = array($columns['res_prefix'], $columns['res_label'], $columns['res_text']); $query = new DB_Multiple_Insert($table); $query->setInsertFields($fields); foreach ($data as $key => $value) { $params = array($columns['res_prefix'] => $prefix, $columns['res_label'] => $key, $columns['res_text'] => $value); $query->addInsertValuesArray($params); } $application->db->PrepareSQL($query); $application->db->DB_Exec(); return true; }
function MULTIPLE_INSERT_TMP_ML_RECORDS() { parent::DB_Multiple_Insert('multilang_data'); }
function __install_ProcessNotifications($xml_tag) { global $application; foreach ($xml_tag->children as $child) { if ($child->name == 'NOTIFICATION') { $_txt_content = array_map("rtrim", file(NOTIFICATIONS_INSTALL_DATA_NOTIFICATIONS_DIR . $child->attributes['TEXTFILE'])); $ntf_action_name = $child->attributes['ACTION']; $ntf_action_id = $this->actions[$ntf_action_name]['id']; $ntf_name = array_shift($_txt_content); $ntf_subject = array_shift($_txt_content); $ntf_body = implode("\n", $_txt_content); //+ : xml $ntf_from_email_custom_address = ''; $ntf_from_email_code = 'EMAIL_STORE_OWNER'; $ntf_active = 'checked'; //- $query = new DB_Insert('notifications'); $query->addInsertValue($ntf_action_id, 'notification_action_id'); $query->addInsertValue($ntf_name, 'notification_name'); $query->addInsertValue($ntf_subject, 'notification_subject'); $query->addInsertValue($ntf_body, 'notification_body'); $query->addInsertValue($ntf_from_email_custom_address, 'notification_from_email_custom_address'); $query->addInsertValue($ntf_from_email_code, 'notification_from_email_code'); $query->addInsertValue($ntf_active, 'notification_active'); $application->db->PrepareSQL($query); $application->db->DB_Exec(); $notification_id = $application->db->DB_Insert_Id(); foreach ($child->children as $ntf_child) { if ($ntf_child->name == 'RECIPIENTS') { $query = new DB_Multiple_Insert('notification_send_to'); $query->setInsertFields(array('notification_id', 'email', 'email_code')); $insert_array = array('notification_id' => $notification_id, 'email' => '', 'email_code' => ''); foreach ($ntf_child->children as $rec_child) { if ($rec_child->name == 'RECIPIENT') { $insert_array['email_code'] = $rec_child->attributes['CODE']; $query->addInsertValuesArray($insert_array); } } $application->db->PrepareSQL($query); $application->db->DB_Exec(); } elseif ($ntf_child->name == 'OPTIONS') { foreach ($ntf_child->children as $options_child) { if ($options_child->name == 'OPTION') { $option_name = $options_child->attributes['NAME']; $default_value = $options_child->attributes['DEFAULT_VALUE']; $option_values = $this->actions[$ntf_action_name]['options'][$option_name]['values']; $query = new DB_Multiple_Insert('option_values_to_notification'); $query->setInsertFields(array('notification_action_option_value_id', 'notification_id', 'value')); $insert_array = array('notification_action_option_value_id' => 0, 'notification_id' => $notification_id, 'value' => $default_value); $_values = array(); foreach ($options_child->children as $option_child) { if ($option_child->name == 'VALUE') { $value_name = $option_child->attributes['NAME']; $value_value = $option_child->attributes['VALUE']; $_values[$value_name] = $value_value; } } foreach ($option_values as $value_name => $value_id) { $_arr = $insert_array; $_arr['notification_action_option_value_id'] = $value_id; if (array_key_exists($value_name, $_values)) { $_arr['value'] = $_values[$value_name]; } $query->addInsertValuesArray($_arr); } $application->db->PrepareSQL($query); $application->db->DB_Exec(); } } } } // blocktags $ntf_blocktags = array(); if (array_key_exists('blocktags', $this->actions[$ntf_action_name])) { $ntf_blocktags = $this->actions[$ntf_action_name]['blocktags']; } if (!empty($ntf_blocktags)) { $insert_array = array('notification_blocktag_id' => 0, 'notification_id' => $notification_id, 'blocktag_body' => ''); $query = new DB_Multiple_Insert('notification_blocktag_bodies'); $query->setInsertFields(array_keys($insert_array)); foreach ($ntf_blocktags as $blocktag_name) { $blocktag_id = $this->blocktags[$blocktag_name]['id']; $blocktag_txt = $this->blocktags[$blocktag_name]['textfile']; $blocktag_body = file_get_contents(NOTIFICATIONS_INSTALL_DATA_BLOCKTAGS_DIR . $blocktag_txt); $_arr = $insert_array; $_arr['notification_blocktag_id'] = $blocktag_id; $_arr['blocktag_body'] = $blocktag_body; $query->addInsertValuesArray($_arr); } $application->db->PrepareSQL($query); $application->db->DB_Exec(); } } } return; }
/** * adds rates to DB from an array * * @param array $data */ function addRatesArrayToDB($data, $sid) { global $application; if (empty($data)) { return; } loadCoreFile('db_multiple_insert.php'); $tables = TaxRateByZip::getTables(); $table = "tax_zip_rates"; $columns = $tables[$table]['columns']; $fields = array($columns["sid"], $columns['zip5'], $columns['zip5low'], $columns['zip5high'], $columns['zip5mask'], $columns['zip4low'], $columns['zip4high'], $columns['rate']); $query = new DB_Multiple_Insert($table); $query->setInsertFields($fields); foreach ($data as $key => $value) { $params = array($columns["sid"] => $sid, $columns['zip5'] => $value["ZipCode"], $columns['zip5low'] => $value["Zip5Low"], $columns['zip5high'] => $value["Zip5High"], $columns['zip5mask'] => $value["Zip5Mask"], $columns['zip4low'] => $value["Zip4Low"], $columns['zip4high'] => $value["Zip4High"], $columns['rate'] => $value["SalesTaxRatePercent"]); $query->addInsertValuesArray($params); } $application->db->PrepareSQL($query); $application->db->DB_Exec(); }