function delManufacturers($mnf_ids) { global $application; $tables = $this->getTables(); $mnf_table = $tables['manufacturers']['columns']; // foreach ($mnf_ids as $mnf_id) { $mnf_info = modApiFunc("Manufacturers", "getManufacturerInfo", $mnf_id); if ($mnf_info['manufacturer_image_id'] !== NULL) { modApiFunc('EventsManager', 'throwEvent', 'ImageFKRemovedEvent', $mnf_info['manufacturer_image_id']); } } $query = new DB_Delete('manufacturers'); $query->Where($mnf_table['manufacturer_id'], DB_IN, '(\'' . implode('\',\'', $mnf_ids) . '\')'); $application->db->PrepareSQL($query); $application->db->DB_Exec(); modApiFunc('EventsManager', 'throwEvent', 'ManufacturerDeleted', $mnf_ids); return; }
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 unsubscribeTempEmails($key, $topics_ids) { global $application; if (empty($topics_ids)) { return; } $tables = Subscriptions::getTables(); $etable = 'subscription_email'; $ecolumns =& $tables[$etable]['columns']; $ttable = 'subscription_temp'; $tcolumns =& $tables[$ttable]['columns']; $dquery = new DB_Delete($etable); $dquery->addUsingTable($etable); $dquery->addUsingTable($ttable); $dquery->WhereValue($tcolumns['action_key'], DB_EQ, $key); $dquery->WhereAND(); $dquery->Where($ecolumns['topic_id'], DB_IN, DBQuery::arrayToIn($topics_ids)); $dquery->WhereAND(); $dquery->WhereField($ecolumns['email_id'], DB_EQ, $tcolumns['email_id']); $application->db->getDB_Result($dquery); }
function delAllImagesFromProducts($products_ids) { global $application; $tables = $this->getTables(); $images_table = $tables['pi_images']['columns']; $query = new DB_Select(); $query->addSelectField($images_table['image_path']); $query->addSelectField($images_table['thumb_path']); $query->Where($images_table['product_id'], DB_IN, "('" . implode("','", $products_ids) . "')"); $res = $application->db->getDB_Result($query); if (count($res) > 0) { //$this->unlinkFiles($res); $query = new DB_Delete('pi_images'); $query->deleteMultiLangField($images_table['alt_text'], $images_table['image_id'], 'Product_Images'); $query->Where($images_table['product_id'], DB_IN, "('" . implode("','", $products_ids) . "')"); $application->db->getDB_Result($query); } return; }
/** * @param $s_info shipping info of the destination * @param $weight weight of the package * @param $rates array of the shipping rates for saving */ function saveRatesToCache($s_info, $weight, $rates) { if ($s_info["isMet"] == false or empty($rates)) { return; } $s_country = modApiFunc("Location", "getCountry", $s_info["validatedData"]["Country"]["value"]); $s_zipcode = $s_info["validatedData"]["Postcode"]["value"]; $s_name = isset($s_info["validatedData"]["Firstname"]["value"]) ? $s_info["validatedData"]["Firstname"]["value"] : ''; $s_name .= isset($s_info["validatedData"]["Lastname"]["value"]) ? $s_info["validatedData"]["Lastname"]["value"] : ''; $hash = md5($s_country . $s_name . $s_zipcode . $weight); $tables = $this->getTables(); $rc_table = $tables['sm_dsr_rates_cache']['columns']; global $application; $query = new DB_Delete('sm_dsr_rates_cache'); $query->Where($rc_table['hash'], DB_EQ, "'{$hash}'"); $application->db->getDB_Result($query); $query = new DB_Delete('sm_dsr_rates_cache'); $query->Where($rc_table['expire'], DB_LT, time()); $application->db->getDB_Result($query); foreach ($rates as $key => $rate_info) { $query = new DB_Insert('sm_dsr_rates_cache'); $query->addInsertValue($hash, $rc_table["hash"]); $query->addInsertValue($rate_info["id"], $rc_table["method_id"]); $query->addInsertValue($rate_info["cost"], $rc_table["rate"]); $query->addInsertValue(time() + 18000, $rc_table["expire"]); $application->db->getDB_Result($query); } return; }
function deleteCustomers($customers_ids) { if (!is_array($customers_ids) or empty($customers_ids)) { return false; } global $application; $ca_tables = $this->getTables(); $co_tables = modApiStaticFunc('Checkout', 'getTables'); $query = new DB_Select(); $query->addSelectTable('orders'); $query->addSelectField($co_tables['orders']['columns']['id'], 'order_id'); $query->Where($co_tables['orders']['columns']['person_id'], DB_IN, "(" . implode(", ", $customers_ids) . ")"); $res = $application->db->getDB_Result($query); $orders_ids = array(); for ($i = 0; $i < count($res); $i++) { $orders_ids[] = $res[$i]['order_id']; } if (!empty($orders_ids)) { modApiFunc('Checkout', 'DeleteOrders', $orders_ids); } $accounts = array(); $query = new DB_Select(); $query->addSelectField($ca_tables['ca_customers']['columns']['customer_account'], 'customer_account'); $query->addSelectTable('ca_customers'); $query->Where($ca_tables['ca_customers']['columns']['customer_id'], DB_IN, "(" . implode(", ", $customers_ids) . ")"); $res = $application->db->getDB_Result($query); for ($i = 0; $i < count($res); $i++) { $accounts[] = $res[$i]['customer_account']; } if (!empty($accounts)) { $query = new DB_Delete('ca_activation_keys'); $query->Where($ca_tables['ca_activation_keys']['columns']['customer_account'], DB_IN, "('" . implode("','", $accounts) . "')"); $application->db->PrepareSQL($query); $application->db->DB_Exec(); } $query = new DB_Delete('ca_person_info_data'); $query->Where($ca_tables['ca_person_info_data']['columns']['customer_id'], DB_IN, "(" . implode(", ", $customers_ids) . ")"); $application->db->PrepareSQL($query); $application->db->DB_Exec(); $query = new DB_Delete('ca_customers'); $query->Where($ca_tables['ca_customers']['columns']['customer_id'], DB_IN, "(" . implode(", ", $customers_ids) . ")"); $application->db->PrepareSQL($query); $application->db->DB_Exec(); return true; }
function OnCategoriesWereDeleted($categories_ids) { if (!is_array($categories_ids) or empty($categories_ids)) { return; } global $application; $tables = $this->getTables(); $fp_table = $tables['fp_links']['columns']; $query = new DB_Delete('fp_links'); $query->Where($fp_table['category_id'], DB_IN, "(" . implode(", ", $categories_ids) . ")"); $application->db->PrepareSQL($query); return $application->db->DB_Exec(); }
function OnProductsWereDeleted($products_ids) { if (!is_array($products_ids) or empty($products_ids)) { return; } global $application; $tables = $this->getTables(); $rp_table = $tables['rp_links']['columns']; $query = new DB_Delete('rp_links'); $query->Where($rp_table['product_id'], DB_IN, "(" . implode(", ", $products_ids) . ")"); $query->WhereOR(); $query->Where($rp_table['rp_id'], DB_IN, "(" . implode(", ", $products_ids) . ")"); $application->db->PrepareSQL($query); return $application->db->DB_Exec(); }
/** * , id - . * @param number $id_messages id */ function deleteMessages($id_messages) { global $application; if (empty($id_messages)) { return; } if (!is_array($id_messages)) { $id_messages = array($id_messages); } execQuery('NLT_DELETE_MESSAGE', array('ids' => $id_messages)); $tables = $this->getTables(); $table = 'newsletter_topics'; $query = new DB_Delete($table); $query->Where($tables[$table]['columns']['letter_id'], DB_IN, DBQuery::arrayToIn($id_messages)); $application->db->PrepareSQL($query); $application->db->DB_Exec(); }
function delCRulesFromEntity($parent_entity, $entity_id, $crules_ids) { global $application; $tables = $this->getTables(); $crules_table = $tables['po_crules']['columns']; /* $query = new DB_Select(); $query->addSelectTable('po_crules'); $query->addSelectField('*'); $query->Where($crules_table['crule_id'], DB_IN, "('".implode("','",$crules_ids)."')"); $res = $application->db->getDB_Result($query); $oids = array(); for($i=0;$i<count($res);$i++) { $oids=array_merge($oids,array_keys($this->_unserialize_combination($res[$i]['sside']))); $oids=array_merge($oids,array_keys($this->_unserialize_combination($res[$i]['lside']))); $oids=array_merge($oids,array_keys($this->_unserialize_combination($res[$i]['rside']))); }; if(!empty($oids) and $this->__isUsedForIT($oids)) $this->updateOptionsSettingsForEntity($parent_entity,$entity_id,array('IT_ACTUAL'=>'N'));*/ $query = new DB_Delete('po_crules'); $query->Where($crules_table['crule_id'], DB_IN, "('" . implode("','", $crules_ids) . "')"); $application->db->PrepareSQL($query); if ($application->db->DB_Exec()) { $this->__rebuildCRulesFormulaForEntity($parent_entity, $entity_id); } else { return false; } }
function delAllFilesFromProducts($products_ids) { global $application; $tables = $this->getTables(); $files_table = $tables['pf_files']['columns']; $query = new DB_Select(); $query->addSelectField($files_table['file_path']); $query->Where($files_table['product_id'], DB_IN, "('" . implode("','", $products_ids) . "')"); $query->WhereAND(); $query->WhereValue($files_table['is_uploaded'], DB_EQ, 'Y'); $res = $application->db->getDB_Result($query); $this->unlinkFiles($res); $query = new DB_Delete('pf_files'); $query->Where($files_table['product_id'], DB_IN, "('" . implode("','", $products_ids) . "')"); $application->db->PrepareSQL($query); $application->db->DB_Exec(); return; }