/** * Creates or updates container. * <i>$container_data</i> must be array with this fields: * <pre>array ( * container_id, * location_id, * position (TOP_PANEL | HEADER | CONTENT | FOOTER), * width (12 | 16) * )</pre> * * @param array $container_data array of container data * @return int|db_result Container id if new grid was created, DB result otherwise */ public static function update($container_data) { return db_replace_into('bm_containers', $container_data); }
function fn_update_discussion($data) { if (!empty($data['for_all_companies'])) { if (isset($data['thread_id'])) { unset($data['thread_id']); } foreach (fn_get_all_companies_ids() as $company) { $data['company_id'] = $company; db_replace_into('discussion', $data); } } else { if (fn_allowed_for('ULTIMATE') && Registry::get('runtime.company_id')) { $data['company_id'] = Registry::get('runtime.company_id'); } db_replace_into('discussion', $data); } return true; }
/** * Updates settings description. * If $object_id, $object_type or $lang_code or value is empty function return false and generate error notification. * * Description data must be array in this format (example): * array( * 'value' => 'General', * 'tooltip' => 'General tab', * 'object_id' => '1', * 'object_type' => 'S', * 'lang_code' => 'en' * ) * * If some parameter will be skipped and function not update it field. * If name or lang_code skipped function adds new description and returns true. * * @param array $description_data Description data * @return bool True on success, false otherwise */ public function updateDescription($description_data) { if (!(empty($description_data['object_type']) || empty($description_data['object_id']) || empty($description_data['lang_code']))) { db_replace_into('settings_descriptions', $description_data); } else { $this->_generateError(__('unable_to_update_setting_description'), __('empty_key_value')); return false; } return true; }
public static function updateStatusColors() { General::connectToOriginalDB(array('table_prefix' => General::formatPrefix())); $statuses = db_get_array("SELECT * FROM ?:status_data WHERE param = 'color'"); foreach ($statuses as $status_data) { if (strpos($status_data['value'], '#') !== 0) { $status_data['value'] = '#' . ($status_data['value'] ? $status_data['value'] : 'ffffff'); db_replace_into('status_data', $status_data); } } }
function fn_se_set_setting($name, $company_id, $lang_code, $value) { if (empty($name) || empty($lang_code)) { return; } db_replace_into('se_settings', array('name' => $name, 'company_id' => $company_id, 'lang_code' => $lang_code, 'value' => $value)); fn_se_get_all_settings(true); // call to update cache }
/** * Clones dynamic object data * * @param string $object_type Object type in DB * @param int $old_object_id Object identifier to get data from * @param int $new_object_id Object identifier to clone * @return bool Always true */ public function cloneDynamicObjectData($object_type, $old_object_id, $new_object_id) { $data = db_get_array("SELECT * FROM ?:bm_blocks_content WHERE object_type=?s AND object_id=?i", $object_type, $old_object_id); foreach ($data as $fields) { $fields['object_id'] = $new_object_id; db_replace_into("bm_blocks_content", $fields); } $data = db_get_array("SELECT * FROM ?:bm_block_statuses WHERE object_type=?s AND FIND_IN_SET(?i, object_ids)", $object_type, $old_object_id); foreach ($data as $fields) { $fields['object_ids'] .= ',' . $new_object_id; db_replace_into("bm_block_statuses", $fields); } return true; }
/** * Updates description of the location with <i>$location_id</i> * <i>$description</i> must be array with this keys: * <pre>array ( * lang_code, (requred) * name, (requred) * title, * meta_description, * meta_keywords, * )</pre> * * @param int $location_id Location identifier * @param array $description Array of description data * @param string $lang_code language code * @return bool True in success, false otherwise */ private function _updateDescription($location_id, $description, $lang_code = DESCR_SL) { if (!empty($location_id) && isset($description['name'])) { if (!isset($description['lang_code'])) { $description['lang_code'] = $lang_code; } $description['location_id'] = $location_id; /** * Processes location description before updating it * @param $description */ fn_set_hook('update_location_description', $location, $dispatch, $lang_code); db_replace_into('bm_locations_descriptions', $description); return true; } else { return false; } }
/** * Updates product tab description * $description must be array in this format: * array ( * lang_code (required) * name (required) * ) * * @param int $tab_id Product tab identifier * @param array $description Array of product tab description data * @return int|db_result Product tab id if new tab was created, DB result otherwise */ private function _updateDescription($tab_id, $description) { if (!empty($tab_id) && !empty($description['lang_code'])) { $description['tab_id'] = $tab_id; /** * Actions before updating product tab description * @param int $tab_id Product tab identifier * @param array $description Array of product tab description data */ fn_set_hook('update_product_tab_description', $tab_id, $description); db_replace_into('product_tabs_descriptions', $description); return true; } else { return false; } }
/** * Updates menu description * $description must be array in this format: * array ( * lang_code (required) * name (required) * ) * @static * @param int $menu_id * @param array $description * @return bool */ public static function updateDescription($menu_id, $description) { if (!empty($menu_id) && !empty($description['lang_code'])) { $description['menu_id'] = $menu_id; /** * Prepare params for sql query before update menu description * @param array $description */ fn_set_hook('update_menu_description', $description); return db_replace_into('menus_descriptions', $description); } else { return false; } }
/** * Creates or updates grid * <i>$grid_data</i> must be array in this format * <pre>array ( * grid_id * container_id * parent_id * order * width - grid 960 param * suffix - grid 960 param * prefix - grid 960 param * omega - grid 960 param * alpha - grid 960 param * wrapper - path to wrapper template relative to "templates" directory * content_align - LEFT|RIGHT|FULL_WIDTH, blocks in this grid will be placed as float left, float right or with width 100% in case. * html_element - name of html element of this grid (div, ul, li, p, etc.) * clear - If 1 then after this grid will be clear div on rendered page * user_class * )</pre> * @static * @param array $grid_data Array of grid data * @return int|db_result Grid id if new grid was created, DB result otherwise */ public static function update($grid_data) { /** * Processes grid data before update it * @param int $grid_data Array of grid data */ fn_set_hook('update_grid', $grid_data); $grid_id = db_replace_into('bm_grids', $grid_data); return $grid_id; }
} var_dump(db_update('d_all_units', $_POST, 'id = ' . $iUnitId)); echo db_error(); echo "--\n"; // Combat stats db_delete('d_combat_stats', 'shooting_unit_id = ' . $iUnitId); foreach ($arrCombatStats as $iToUnitId => $s) { if (!empty($s['ratio']) && !empty($s['target_priority'])) { var_dump(db_insert('d_combat_stats', array('shooting_unit_id' => $iUnitId, 'receiving_unit_id' => $iToUnitId, 'ratio' => 1.0 / (double) $s['ratio'], 'target_priority' => $s['target_priority']))); } } echo "--\n"; // Costs db_delete('d_unit_costs', 'unit_id = ' . $iUnitId); foreach ($arrCosts as $iResourceId => $iAmount) { var_dump(db_replace_into('d_unit_costs', array('unit_id' => $iUnitId, 'resource_id' => $iResourceId, 'amount' => $iAmount))); } db_delete('d_unit_costs', 'amount = 0'); exit; } if (isset($_GET['new_unit_T'], $_GET['required'])) { var_dump(db_insert('d_all_units', array('T' => $_GET['new_unit_T'], 'unit' => 'NEW', 'r_d_required_id' => $_GET['required']))); echo db_error(); header('Location: ' . $_SERVER['HTTP_REFERER']); exit; } $arrRD = db_select_fields('d_r_d_available', 'id, CONCAT(UPPER(T),\': \',name)', '1 ORDER BY T ASC, id ASC'); ?> <style type="text/css"> select, input { font-size : 9px; } </style>
function fn_uc_update_setting_value_by_id($object_id, $value, $company_id = null) { $table = 'settings_objects'; $data = array('object_id' => $object_id, 'value' => $value); if (fn_allowed_for('ULTIMATE') && !is_null($company_id)) { $table = 'settings_vendor_values'; } db_replace_into($table, $data); }
foreach ($_POST['skills'] as $iRD => $arrSkills) { foreach ($arrSkills as $k => $d) { if ('' === $d['skill_id'] || '' === $d['value']) { unset($_POST['skills'][$iRD][$k]); } } if (empty($_POST['skills'][$iRD])) { unset($_POST['skills'][$iRD]); } unset($arrSkills); } print_r($_POST['skills']); db_query('DELETE FROM d_skills_per_r_d;'); foreach ($_POST['skills'] as $iRD => $arrSkills) { foreach ($arrSkills as $d) { db_replace_into('d_skills_per_r_d', array('r_d_id' => $iRD, 'skill_id' => (int) $d['skill_id'], 'value' => (int) $d['value'])); } } echo "\n" . 'delete from d_skills_per_r_d: '; var_dump(db_delete('d_skills_per_r_d', '0 >= required_value')); echo "\n" . 'TRUNCATE d_r_d_requires: '; var_dump(db_query("DELETE FROM d_r_d_requires;")); echo db_error(); $szInserts = ''; foreach ($arrRequires as $iRDId => $arrRDs) { $szInserts .= ",(" . $iRDId . "," . implode("),(" . $iRDId . ",", $arrRDs) . ")"; } echo $szSqlQuery = 'INSERT INTO d_r_d_requires (r_d_id, r_d_requires_id) VALUES ' . substr($szInserts, 1) . ';' . "\n"; db_query($szSqlQuery) or die("\n\n" . db_error()); echo "\n" . 'TRUNCATE d_r_d_excludes: '; var_dump(db_query("DELETE FROM d_r_d_excludes;"));