本文整理汇总了PHP中db_insert_id函数的典型用法代码示例。如果您正苦于以下问题:PHP db_insert_id函数的具体用法?PHP db_insert_id怎么用?PHP db_insert_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_insert_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sn_mm_points_change
function sn_mm_points_change($user_id, $change_type, $metamatter, $comment = false, $already_changed = false, &$result)
{
global $debug, $mm_change_legit, $user, $config;
if (!$user_id || !($metamatter = floatval($metamatter))) {
return false;
}
$mm_change_legit = true;
$sn_data_metamatter_db_name = pname_resource_name(RES_METAMATTER);
if ($already_changed) {
$result = -1;
} else {
$metamatter_total = $metamatter > 0 ? $metamatter : 0;
db_user_set_by_id($user_id, "`{$sn_data_metamatter_db_name}` = `{$sn_data_metamatter_db_name}` + '{$metamatter}'" . ($metamatter > 0 ? ", `immortal` = IF(`metamatter_total` + '{$metamatter_total}' >= {$config->player_metamatter_immortal}, NOW(), `immortal`), `metamatter_total` = `metamatter_total` + '{$metamatter_total}'" : ''));
$result = db_affected_rows();
}
if ($result) {
$page_url = db_escape($_SERVER['SCRIPT_NAME']);
if (is_array($comment)) {
$comment = call_user_func_array('sprintf', $comment);
}
$comment = db_escape($comment);
$row = db_user_by_id($user_id, false, 'username');
$row['username'] = db_escape($row['username']);
doquery("INSERT INTO {{log_metamatter}} SET\n `user_id` = {$user_id},\n `username` = '{$row['username']}',\n `reason` = {$change_type},\n `amount` = {$metamatter},\n `comment` = '{$comment}',\n `page` = '{$page_url}'\n ;");
$result = db_insert_id();
if ($user['id'] == $user_id) {
$user['metamatter'] += $metamatter;
}
} else {
$debug->warning("Error adjusting Metamatter for player ID {$user_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402);
}
$mm_change_legit = false;
return $result;
}
示例2: news_create
/**
* Add a news item
*
* @param integer $p_project_id A project identifier.
* @param integer $p_poster_id The user id of poster.
* @param integer $p_view_state View state.
* @param boolean $p_announcement Whether article is an announcement.
* @param string $p_headline News Headline.
* @param string $p_body News Body.
* @return integer news article id
*/
function news_create($p_project_id, $p_poster_id, $p_view_state, $p_announcement, $p_headline, $p_body)
{
if (is_blank($p_headline)) {
error_parameters(lang_get('headline'));
trigger_error(ERROR_EMPTY_FIELD, ERROR);
}
if (is_blank($p_body)) {
error_parameters(lang_get('body'));
trigger_error(ERROR_EMPTY_FIELD, ERROR);
}
db_param_push();
$t_query = 'INSERT INTO {news}
( project_id, poster_id, date_posted, last_modified,
view_state, announcement, headline, body )
VALUES
( ' . db_param() . ',
' . db_param() . ',
' . db_param() . ',
' . db_param() . ',
' . db_param() . ',
' . db_param() . ',
' . db_param() . ',
' . db_param() . '
)';
db_query($t_query, array((int) $p_project_id, (int) $p_poster_id, db_now(), db_now(), (int) $p_view_state, $p_announcement, $p_headline, $p_body));
$t_news_id = db_insert_id(db_get_table('news'));
return $t_news_id;
}
示例3: email_queue_add
function email_queue_add($p_email_data)
{
$t_email_data = email_queue_prepare_db($p_email_data);
# email cannot be blank
if (is_blank($t_email_data->email)) {
error_parameters(lang_get('email'));
trigger_error(ERROR_EMPTY_FIELD, ERROR);
}
# subject cannot be blank
if (is_blank($t_email_data->subject)) {
error_parameters(lang_get('subject'));
trigger_error(ERROR_EMPTY_FIELD, ERROR);
}
# body cannot be blank
if (is_blank($t_email_data->body)) {
error_parameters(lang_get('body'));
trigger_error(ERROR_EMPTY_FIELD, ERROR);
}
$t_email_table = config_get('mantis_email_table');
$c_email = $t_email_data->email;
$c_subject = $t_email_data->subject;
$c_body = $t_email_data->body;
$c_metadata = serialize($t_email_data->metadata);
$query = "INSERT INTO {$t_email_table}\r\n\t\t\t\t ( email,\r\n\t\t\t\t subject,\r\n\t\t\t\t\t body,\r\n\t\t\t\t\t submitted,\r\n\t\t\t\t\t metadata)\r\n\t\t\t\t VALUES\r\n\t\t\t\t ( '{$c_email}',\r\n\t\t\t\t '{$c_subject}',\r\n\t\t\t\t '{$c_body}',\r\n\t\t\t\t\t " . db_now() . ",\r\n\t\t\t\t\t '{$c_metadata}'\r\n\t\t\t\t\t)";
db_query($query);
return db_insert_id($t_email_table);
}
示例4: install
function install($module)
{
global $db, $messageStack;
$error = false;
if (!db_field_exists(TABLE_INVENTORY, 'catalog')) {
// setup new tab in table inventory
$result = $db->Execute("select id FROM " . TABLE_EXTRA_TABS . " WHERE tab_name='ZenCart'");
if ($result->RecordCount() == 0) {
$sql_data_array = array('module_id' => 'inventory', 'tab_name' => 'ZenCart', 'description' => 'ZenCart Catalog', 'sort_order' => '49');
db_perform(TABLE_EXTRA_TABS, $sql_data_array);
$tab_id = db_insert_id();
} else {
$tab_id = $result->fields['id'];
}
gen_add_audit_log(ZENCART_LOG_TABS . TEXT_ADD, 'zencart');
// setup extra fields for inventory
$sql_data_array = array('module_id' => 'inventory', 'tab_id' => $tab_id, 'entry_type' => 'check_box', 'field_name' => 'catalog', 'description' => ZENCART_CATALOG_ADD, 'sort_order' => 10, 'use_in_inventory_filter' => '1', 'params' => serialize(array('type' => 'check_box', 'select' => '0', 'inventory_type' => 'ai:ci:ds:sf:ma:ia:lb:mb:ms:mi:ns:sa:sr:sv:si:')));
db_perform(TABLE_EXTRA_FIELDS, $sql_data_array);
$db->Execute("alter table " . TABLE_INVENTORY . " add column catalog enum('0','1') default '0'");
$sql_data_array = array('module_id' => 'inventory', 'tab_id' => $tab_id, 'entry_type' => 'text', 'field_name' => 'category_id', 'description' => ZENCART_CATALOG_CATEGORY_ID, 'sort_order' => 20, 'use_in_inventory_filter' => '1', 'params' => serialize(array('type' => 'text', 'length' => '64', 'default' => '', 'inventory_type' => 'ai:ci:ds:sf:ma:ia:lb:mb:ms:mi:ns:sa:sr:sv:si:')));
db_perform(TABLE_EXTRA_FIELDS, $sql_data_array);
$db->Execute("alter table " . TABLE_INVENTORY . " add column category_id varchar(64) default ''");
$sql_data_array = array('module_id' => 'inventory', 'tab_id' => $tab_id, 'entry_type' => 'text', 'field_name' => 'manufacturer', 'description' => ZENCART_CATALOG_MANUFACTURER, 'sort_order' => 30, 'use_in_inventory_filter' => '1', 'params' => serialize(array('type' => 'text', 'length' => '64', 'default' => '', 'inventory_type' => 'ai:ci:ds:sf:ma:ia:lb:mb:ms:mi:ns:sa:sr:sv:si:')));
db_perform(TABLE_EXTRA_FIELDS, $sql_data_array);
$db->Execute("alter table " . TABLE_INVENTORY . " add column manufacturer varchar(64) default ''");
$sql_data_array = array('module_id' => 'inventory', 'tab_id' => $tab_id, 'entry_type' => 'text', 'field_name' => 'ProductModel', 'description' => ZENCART_CATALOG_MODEL, 'sort_order' => 40, 'use_in_inventory_filter' => '1', 'params' => serialize(array('type' => 'text', 'length' => '64', 'default' => '', 'inventory_type' => 'ai:ci:ds:sf:ma:ia:lb:mb:ms:mi:ns:sa:sr:sv:si:')));
db_perform(TABLE_EXTRA_FIELDS, $sql_data_array);
$db->Execute("alter table " . TABLE_INVENTORY . " add column ProductModel varchar(64) default ''");
$sql_data_array = array('module_id' => 'inventory', 'tab_id' => $tab_id, 'entry_type' => 'text', 'field_name' => 'ProductURL', 'description' => ZENCART_CATALOG_URL, 'sort_order' => 50, 'use_in_inventory_filter' => '1', 'params' => serialize(array('type' => 'text', 'length' => '64', 'default' => '', 'inventory_type' => 'ai:ci:ds:sf:ma:ia:lb:mb:ms:mi:ns:sa:sr:sv:si:')));
db_perform(TABLE_EXTRA_FIELDS, $sql_data_array);
$db->Execute("alter table " . TABLE_INVENTORY . " add column ProductURL varchar(64) default ''");
gen_add_audit_log(ZENCART_LOG_FIELDS . TEXT_NEW, 'zencart - catalog');
}
return $error;
}
示例5: write_customer
function write_customer($email, $name, $company, $address, $phone, $fax, $currency)
{
global $paypal_sales_type_id, $paypal_tax_group_id, $paypal_salesman, $paypal_area, $paypal_location, $paypal_credit_status, $paypal_shipper;
global $SysPrefs;
log_message("Memory, write_customer start:" . memory_get_usage());
$customer_id = find_customer_by_email($email);
if (empty($customer_id)) {
$customer_id = find_customer_by_name($company);
}
if (empty($customer_id)) {
//it is a new customer
begin_transaction();
add_customer($company, substr($company, 0, 30), $address, '', $currency, 0, 0, $paypal_credit_status, -1, 0, 0, $SysPrefs->default_credit_limit(), $paypal_sales_type_id, 'PayPal');
$customer_id = db_insert_id();
add_branch($customer_id, $company, substr($company, 0, 30), $address, $paypal_salesman, $paypal_area, $paypal_tax_group_id, '', get_company_pref('default_sales_discount_act'), get_company_pref('debtors_act'), get_company_pref('default_prompt_payment_act'), $paypal_location, $address, 0, 0, $paypal_shipper, 'PayPal');
$selected_branch = db_insert_id();
$nameparts = explode(" ", $name);
$firstname = "";
for ($i = 0; $i < count($nameparts) - 1; $i++) {
if (!empty($firstname)) {
$firstname .= " ";
}
$firstname .= $nameparts[$i];
}
$lastname = $nameparts[count($nameparts) - 1];
add_crm_person('paypal', $firstname, $lastname, $address, $phone, '', $fax, $email, '', '');
add_crm_contact('customer', 'general', $selected_branch, db_insert_id());
commit_transaction();
} else {
$selected_branch = 0;
}
log_message("Memory, write_customer end:" . memory_get_usage());
return array($customer_id, $selected_branch);
}
示例6: profile_create
/**
* Create a new profile for the user, return the ID of the new profile
* @param int $p_user_id
* @param string $p_platform
* @param string $p_os
* @param string $p_os_build
* @param string $p_description
* @return int
*/
function profile_create($p_user_id, $p_platform, $p_os, $p_os_build, $p_description)
{
$p_user_id = (int) $p_user_id;
if (ALL_USERS != $p_user_id) {
user_ensure_unprotected($p_user_id);
}
# platform cannot be blank
if (is_blank($p_platform)) {
error_parameters(lang_get('platform'));
trigger_error(ERROR_EMPTY_FIELD, ERROR);
}
# os cannot be blank
if (is_blank($p_os)) {
error_parameters(lang_get('operating_system'));
trigger_error(ERROR_EMPTY_FIELD, ERROR);
}
# os_build cannot be blank
if (is_blank($p_os_build)) {
error_parameters(lang_get('version'));
trigger_error(ERROR_EMPTY_FIELD, ERROR);
}
$t_user_profile_table = db_get_table('user_profile');
# Add profile
$query = "INSERT INTO {$t_user_profile_table}\n\t\t\t\t ( user_id, platform, os, os_build, description )\n\t\t\t\t VALUES\n\t\t\t\t ( " . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ' )';
db_query_bound($query, array($p_user_id, $p_platform, $p_os, $p_os_build, $p_description));
return db_insert_id($t_user_profile_table);
}
示例7: email_queue_add
/**
* Add to email queue
* @param EmailData $p_email_data
* @return int
*/
function email_queue_add($p_email_data)
{
$t_email_data = email_queue_prepare_db($p_email_data);
# email cannot be blank
if (is_blank($t_email_data->email)) {
error_parameters(lang_get('email'));
trigger_error(ERROR_EMPTY_FIELD, ERROR);
}
# subject cannot be blank
if (is_blank($t_email_data->subject)) {
error_parameters(lang_get('subject'));
trigger_error(ERROR_EMPTY_FIELD, ERROR);
}
# body cannot be blank
if (is_blank($t_email_data->body)) {
error_parameters(lang_get('body'));
trigger_error(ERROR_EMPTY_FIELD, ERROR);
}
$t_email_table = db_get_table('mantis_email_table');
$c_email = $t_email_data->email;
$c_subject = $t_email_data->subject;
$c_body = $t_email_data->body;
$c_metadata = serialize($t_email_data->metadata);
$query = "INSERT INTO {$t_email_table}\n\t\t\t\t ( email,\n\t\t\t\t subject,\n\t\t\t\t\t body,\n\t\t\t\t\t submitted,\n\t\t\t\t\t metadata)\n\t\t\t\t VALUES\n\t\t\t\t ( " . db_param() . ",\n\t\t\t\t " . db_param() . ",\n\t\t\t\t " . db_param() . ",\n\t\t\t\t\t " . db_param() . ",\n\t\t\t\t\t " . db_param() . "\n\t\t\t\t\t)";
db_query_bound($query, array($c_email, $c_subject, $c_body, db_now(), $c_metadata));
$t_id = db_insert_id($t_email_table, 'email_id');
log_event(LOG_EMAIL, "message #{$t_id} queued");
return $t_id;
}
示例8: create_input_timevalue
function create_input_timevalue($user, $name, $nodeid, $time, $value)
{
$time = date("Y-n-j H:i:s", $time);
db_query("INSERT INTO input (userid,name,nodeid,time,value) VALUES ('{$user}','{$name}','{$nodeid}','{$time}','{$value}')");
$inputid = db_insert_id();
return $inputid;
}
示例9: profile_create
/**
* Create a new profile for the user, return the ID of the new profile
* @param integer $p_user_id A valid user identifier.
* @param string $p_platform Value for profile platform.
* @param string $p_os Value for profile operating system.
* @param string $p_os_build Value for profile operation system build.
* @param string $p_description Description of profile.
* @return integer
*/
function profile_create($p_user_id, $p_platform, $p_os, $p_os_build, $p_description)
{
$p_user_id = (int) $p_user_id;
if (ALL_USERS != $p_user_id) {
user_ensure_unprotected($p_user_id);
}
# platform cannot be blank
if (is_blank($p_platform)) {
error_parameters(lang_get('platform'));
trigger_error(ERROR_EMPTY_FIELD, ERROR);
}
# os cannot be blank
if (is_blank($p_os)) {
error_parameters(lang_get('os'));
trigger_error(ERROR_EMPTY_FIELD, ERROR);
}
# os_build cannot be blank
if (is_blank($p_os_build)) {
error_parameters(lang_get('version'));
trigger_error(ERROR_EMPTY_FIELD, ERROR);
}
# Add profile
db_param_push();
$t_query = 'INSERT INTO {user_profile}
( user_id, platform, os, os_build, description )
VALUES
( ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ' )';
db_query($t_query, array($p_user_id, $p_platform, $p_os, $p_os_build, $p_description));
return db_insert_id(db_get_table('user_profile'));
}
示例10: newProductBacklog
function newProductBacklog()
{
global $agilemantis_au;
// Check if team-user name fits into MantisBT regulations
if (!(utf8_strlen($this->name) < 22 && user_is_name_valid($this->name) && user_is_name_unique($this->name))) {
return null;
}
$p_username = $this->generateTeamUser($this->name);
$p_email = $this->email;
$p_email = trim($p_email);
$t_seed = $p_email . $p_username;
$t_password = auth_generate_random_password($t_seed);
if (user_is_name_unique($p_username) === true) {
user_create($p_username, $t_password, $p_email, 55, false, true, 'Team-User-' . $_POST['pbl_name']);
} else {
$t_user_id = $this->getUserIdByName($p_username);
user_set_field($t_user_id, 'email', $p_email);
}
$user_id = $this->getLatestUser();
$agilemantis_au->setAgileMantisUserRights($user_id, 1, 0, 0);
if ($this->team == 0) {
$this->team = $this->getLatestUser();
}
$t_sql = "INSERT INTO gadiv_productbacklogs (name, description, user_id) VALUES ( " . db_param(0) . ", " . db_param(1) . ", " . db_param(2) . ") ";
$t_params = array($this->name, $this->description, $user_id);
db_query_bound($t_sql, $t_params);
$this->id = db_insert_id("gadiv_productbacklogs");
$this->user_id = $user_id;
return $this->id;
}
示例11: profile_create
function profile_create($p_user_id, $p_platform, $p_os, $p_os_build, $p_description)
{
$c_user_id = db_prepare_int($p_user_id);
$c_platform = db_prepare_string($p_platform);
$c_os = db_prepare_string($p_os);
$c_os_build = db_prepare_string($p_os_build);
$c_description = db_prepare_string($p_description);
if (ALL_USERS != $p_user_id) {
user_ensure_unprotected($p_user_id);
}
# platform cannot be blank
if (is_blank($c_platform)) {
error_parameters(lang_get('platform'));
trigger_error(ERROR_EMPTY_FIELD, ERROR);
}
# os cannot be blank
if (is_blank($c_os)) {
error_parameters(lang_get('operating_system'));
trigger_error(ERROR_EMPTY_FIELD, ERROR);
}
# os_build cannot be blank
if (is_blank($c_os_build)) {
error_parameters(lang_get('version'));
trigger_error(ERROR_EMPTY_FIELD, ERROR);
}
$t_user_profile_table = config_get('mantis_user_profile_table');
# Add profile
$query = "INSERT INTO {$t_user_profile_table}\n\t\t\t\t ( user_id, platform, os, os_build, description )\n\t\t\t\t VALUES\n\t\t\t\t ( '{$c_user_id}', '{$c_platform}', '{$c_os}', '{$c_os_build}', '{$c_description}' )";
db_query($query);
return db_insert_id($t_user_profile_table);
}
示例12: order_new
/**
* 生成一个新的订单
*
* @param $sid 服务(商品)编号
* @param $amount 服务(商品)价格,如果不指定则使用数据库中记录的价格
* @return 成功返回订单信息数组,包含 uid, email, orderid 等信息,失败返回 false
*/
function order_new($sid, $amount = -1)
{
$user = user_isonline();
if ($user === false) {
vpn_log('User is not online, cant create new order');
return false;
}
$sid = (int) $sid;
$sql = "SELECT * FROM service WHERE id={$sid}";
$res = db_query($sql);
if ($res == false || db_num_rows($res) == 0) {
vpn_log('No such service id: ' . $sid);
return false;
}
$arr = db_fetch_array($res);
$ts = time(NULL);
$uid = $user['id'];
if ($amount < 0) {
$amount = $arr['price'];
/// 数据库中的金额单位是(分)
}
$sql = "INSERT INTO `order` (uid, createtime, amount, serviceid) VALUES ({$uid}, {$ts}, {$amount}, {$sid})";
$res = db_query($sql);
if ($res === false) {
return false;
}
$user['orderid'] = db_insert_id();
return $user;
}
示例13: sn_ube_report_save
function sn_ube_report_save(&$combat_data)
{
// Если уже есть ИД репорта - значит репорт был взят из таблицы. С таким мы не работаем
if ($combat_data[UBE_REPORT_CYPHER]) {
return false;
}
// Генерируем уникальный секретный ключ и проверяем наличие в базе
do {
$combat_data[UBE_REPORT_CYPHER] = sys_random_string(32);
} while (doquery("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$combat_data[UBE_REPORT_CYPHER]}' LIMIT 1 FOR UPDATE", true));
// Инициализация таблицы для пакетной вставки информации
$sql_perform = array('ube_report_player' => array(array('`ube_report_id`', '`ube_report_player_player_id`', '`ube_report_player_name`', '`ube_report_player_attacker`', '`ube_report_player_bonus_attack`', '`ube_report_player_bonus_shield`', '`ube_report_player_bonus_armor`')), 'ube_report_fleet' => array(array('`ube_report_id`', '`ube_report_fleet_player_id`', '`ube_report_fleet_fleet_id`', '`ube_report_fleet_planet_id`', '`ube_report_fleet_planet_name`', '`ube_report_fleet_planet_galaxy`', '`ube_report_fleet_planet_system`', '`ube_report_fleet_planet_planet`', '`ube_report_fleet_planet_planet_type`', '`ube_report_fleet_resource_metal`', '`ube_report_fleet_resource_crystal`', '`ube_report_fleet_resource_deuterium`', '`ube_report_fleet_bonus_attack`', '`ube_report_fleet_bonus_shield`', '`ube_report_fleet_bonus_armor`')), 'ube_report_outcome_fleet' => array(array('`ube_report_id`', '`ube_report_outcome_fleet_fleet_id`', '`ube_report_outcome_fleet_resource_lost_metal`', '`ube_report_outcome_fleet_resource_lost_crystal`', '`ube_report_outcome_fleet_resource_lost_deuterium`', '`ube_report_outcome_fleet_resource_dropped_metal`', '`ube_report_outcome_fleet_resource_dropped_crystal`', '`ube_report_outcome_fleet_resource_dropped_deuterium`', '`ube_report_outcome_fleet_resource_loot_metal`', '`ube_report_outcome_fleet_resource_loot_crystal`', '`ube_report_outcome_fleet_resource_loot_deuterium`', '`ube_report_outcome_fleet_resource_lost_in_metal`')), 'ube_report_outcome_unit' => array(array('`ube_report_id`', '`ube_report_outcome_unit_fleet_id`', '`ube_report_outcome_unit_unit_id`', '`ube_report_outcome_unit_restored`', '`ube_report_outcome_unit_lost`', '`ube_report_outcome_unit_sort_order`')), 'ube_report_unit' => array(array('`ube_report_id`', '`ube_report_unit_player_id`', '`ube_report_unit_fleet_id`', '`ube_report_unit_round`', '`ube_report_unit_unit_id`', '`ube_report_unit_count`', '`ube_report_unit_boom`', '`ube_report_unit_attack`', '`ube_report_unit_shield`', '`ube_report_unit_armor`', '`ube_report_unit_attack_base`', '`ube_report_unit_shield_base`', '`ube_report_unit_armor_base`', '`ube_report_unit_sort_order`')));
// Сохраняем общую информацию о бое
$outcome =& $combat_data[UBE_OUTCOME];
doquery("INSERT INTO `{{ube_report}}`\n SET\n `ube_report_cypher` = '{$combat_data[UBE_REPORT_CYPHER]}',\n `ube_report_time_combat` = '" . date(FMT_DATE_TIME_SQL, $combat_data[UBE_TIME]) . "',\n `ube_report_time_spent` = {$combat_data[UBE_TIME_SPENT]},\n\n `ube_report_combat_admin` = " . (int) $combat_data[UBE_OPTIONS][UBE_COMBAT_ADMIN] . ",\n `ube_report_mission_type` = {$combat_data[UBE_OPTIONS][UBE_MISSION_TYPE]},\n\n `ube_report_combat_result` = {$outcome[UBE_COMBAT_RESULT]},\n `ube_report_combat_sfr` = " . (int) $outcome[UBE_SFR] . ",\n\n `ube_report_debris_metal` = " . (double) $outcome[UBE_DEBRIS][RES_METAL] . ",\n `ube_report_debris_crystal` = " . (double) $outcome[UBE_DEBRIS][RES_CRYSTAL] . ",\n\n `ube_report_planet_id` = " . (int) $outcome[UBE_PLANET][PLANET_ID] . ",\n `ube_report_planet_name` = '" . db_escape($outcome[UBE_PLANET][PLANET_NAME]) . "',\n `ube_report_planet_size` = " . (int) $outcome[UBE_PLANET][PLANET_SIZE] . ",\n `ube_report_planet_galaxy` = " . (int) $outcome[UBE_PLANET][PLANET_GALAXY] . ",\n `ube_report_planet_system` = " . (int) $outcome[UBE_PLANET][PLANET_SYSTEM] . ",\n `ube_report_planet_planet` = " . (int) $outcome[UBE_PLANET][PLANET_PLANET] . ",\n `ube_report_planet_planet_type` = " . (int) $outcome[UBE_PLANET][PLANET_TYPE] . ",\n\n `ube_report_moon` = " . (int) $outcome[UBE_MOON] . ",\n `ube_report_moon_chance` = " . (int) $outcome[UBE_MOON_CHANCE] . ",\n `ube_report_moon_size` = " . (double) $outcome[UBE_MOON_SIZE] . ",\n\n `ube_report_moon_reapers` = " . (int) $outcome[UBE_MOON_REAPERS] . ",\n `ube_report_moon_destroy_chance` = " . (int) $outcome[UBE_MOON_DESTROY_CHANCE] . ",\n `ube_report_moon_reapers_die_chance` = " . (int) $outcome[UBE_MOON_REAPERS_DIE_CHANCE] . "\n ");
$ube_report_id = $combat_data[UBE_REPORT_ID] = db_insert_id();
// Сохраняем общую информацию по игрокам
foreach ($combat_data[UBE_PLAYERS] as $player_id => &$player_info) {
$sql_perform['ube_report_player'][] = array($ube_report_id, $player_id, "'" . db_escape($player_info[UBE_NAME]) . "'", (int) $player_info[UBE_ATTACKER], (double) $player_info[UBE_BONUSES][UBE_ATTACK], (double) $player_info[UBE_BONUSES][UBE_SHIELD], (double) $player_info[UBE_BONUSES][UBE_ARMOR]);
}
// Всякая информация по флотам
$unit_sort_order = 0;
foreach ($combat_data[UBE_FLEETS] as $fleet_id => &$fleet_info) {
// Сохраняем общую информацию по флотам
$sql_perform['ube_report_fleet'][] = array($ube_report_id, $fleet_info[UBE_OWNER], $fleet_id, (double) $fleet_info[UBE_PLANET][PLANET_ID], "'" . db_escape($fleet_info[UBE_PLANET][PLANET_NAME]) . "'", (int) $fleet_info[UBE_PLANET][PLANET_GALAXY], (int) $fleet_info[UBE_PLANET][PLANET_SYSTEM], (int) $fleet_info[UBE_PLANET][PLANET_PLANET], (int) $fleet_info[UBE_PLANET][PLANET_TYPE], (double) $fleet_info[UBE_RESOURCES][RES_METAL], (double) $fleet_info[UBE_RESOURCES][RES_CRYSTAL], (double) $fleet_info[UBE_RESOURCES][RES_DEUTERIUM], (double) $fleet_info[UBE_BONUSES][UBE_ATTACK], (double) $fleet_info[UBE_BONUSES][UBE_SHIELD], (double) $fleet_info[UBE_BONUSES][UBE_ARMOR]);
// Сохраняем итоговую информацию по ресурсам флота - потеряно, выброшено, увезено
$fleet_outcome_data =& $outcome[UBE_FLEETS][$fleet_id];
$sql_perform['ube_report_outcome_fleet'][] = array($ube_report_id, $fleet_id, (double) $fleet_outcome_data[UBE_RESOURCES_LOST][RES_METAL], (double) $fleet_outcome_data[UBE_RESOURCES_LOST][RES_CRYSTAL], (double) $fleet_outcome_data[UBE_RESOURCES_LOST][RES_DEUTERIUM], (double) $fleet_outcome_data[UBE_CARGO_DROPPED][RES_METAL], (double) $fleet_outcome_data[UBE_CARGO_DROPPED][RES_CRYSTAL], (double) $fleet_outcome_data[UBE_CARGO_DROPPED][RES_DEUTERIUM], (double) $fleet_outcome_data[UBE_RESOURCES_LOOTED][RES_METAL], (double) $fleet_outcome_data[UBE_RESOURCES_LOOTED][RES_CRYSTAL], (double) $fleet_outcome_data[UBE_RESOURCES_LOOTED][RES_DEUTERIUM], (double) $fleet_outcome_data[UBE_RESOURCES_LOST_IN_METAL][RES_METAL]);
// Сохраняем результаты по юнитам - потеряно и восстановлено
foreach ($fleet_info[UBE_COUNT] as $unit_id => $unit_count) {
if ($fleet_outcome_data[UBE_UNITS_LOST][$unit_id] || $fleet_outcome_data[UBE_DEFENCE_RESTORE][$unit_id]) {
$unit_sort_order++;
$sql_perform['ube_report_outcome_unit'][] = array($ube_report_id, $fleet_id, $unit_id, (double) $fleet_outcome_data[UBE_DEFENCE_RESTORE][$unit_id], (double) $fleet_outcome_data[UBE_UNITS_LOST][$unit_id], $unit_sort_order);
}
}
}
// Сохраняем информацию о раундах
$unit_sort_order = 0;
foreach ($combat_data[UBE_ROUNDS] as $round => &$round_data) {
foreach ($round_data[UBE_FLEETS] as $fleet_id => &$fleet_data) {
foreach ($fleet_data[UBE_COUNT] as $unit_id => $unit_count) {
$unit_sort_order++;
$sql_perform['ube_report_unit'][] = array($ube_report_id, $fleet_data[UBE_FLEET_INFO][UBE_OWNER], $fleet_id, $round, $unit_id, $unit_count, (int) $fleet_data[UBE_UNITS_BOOM][$unit_id], $fleet_data[UBE_ATTACK][$unit_id], $fleet_data[UBE_SHIELD][$unit_id], $fleet_data[UBE_ARMOR][$unit_id], $fleet_data[UBE_ATTACK_BASE][$unit_id], $fleet_data[UBE_SHIELD_BASE][$unit_id], $fleet_data[UBE_ARMOR_BASE][$unit_id], $unit_sort_order);
}
}
}
// Пакетная вставка данных
foreach ($sql_perform as $table_name => $table_data) {
if (count($table_data) < 2) {
continue;
}
foreach ($table_data as &$record_data) {
$record_data = '(' . implode(',', $record_data) . ')';
}
$fields = $table_data[0];
unset($table_data[0]);
doquery("INSERT INTO {{{$table_name}}} {$fields} VALUES " . implode(',', $table_data));
}
return $combat_data[UBE_REPORT_CYPHER];
}
示例14: create_feed
function create_feed($userid, $name, $NoOfDataFields, $datatype)
{
// Check if feed of given name by the user already exists
$feedid = get_feed_id($userid, $name);
if ($feedid != 0) {
return $feedid;
}
$result = db_query("INSERT INTO feeds (name,status,datatype) VALUES ('{$name}','0','{$datatype}')");
// Create the feed entry
$feedid = db_insert_id();
if ($feedid > 0) {
db_query("INSERT INTO feed_relation (userid,feedid) VALUES ('{$userid}','{$feedid}')");
// Create a user->feed relation
$feedname = "feed_" . $feedid;
// Feed name
if ($NoOfDataFields == 1) {
// Create a table with one data field
$result = db_query("CREATE TABLE {$feedname} (\n\t time INT UNSIGNED, data float,\n INDEX ( `time` ))");
}
if ($NoOfDataFields == 2) {
// Create a table with two data fields
$result = db_query("CREATE TABLE {$feedname} (\n\t time INT UNSIGNED, data float, data2 float,\n INDEX ( `time` ))");
}
return $feedid;
// Return created feed id
} else {
return 0;
}
}
示例15: handle_submit
function handle_submit(&$selected_id)
{
global $path_to_root, $Ajax, $auto_create_branch;
if (!can_process()) {
return;
}
if ($selected_id) {
update_customer($_POST['customer_id'], $_POST['CustName'], $_POST['cust_ref'], $_POST['address'], $_POST['tax_id'], $_POST['curr_code'], $_POST['dimension_id'], $_POST['dimension2_id'], $_POST['credit_status'], $_POST['payment_terms'], input_num('discount') / 100, input_num('pymt_discount') / 100, input_num('credit_limit'), $_POST['sales_type'], $_POST['notes']);
update_record_status($_POST['customer_id'], $_POST['inactive'], 'debtors_master', 'debtor_no');
$Ajax->activate('customer_id');
// in case of status change
display_notification(_("Customer has been updated."));
} else {
//it is a new customer
begin_transaction();
add_customer($_POST['CustName'], $_POST['cust_ref'], $_POST['address'], $_POST['tax_id'], $_POST['curr_code'], $_POST['dimension_id'], $_POST['dimension2_id'], $_POST['credit_status'], $_POST['payment_terms'], input_num('discount') / 100, input_num('pymt_discount') / 100, input_num('credit_limit'), $_POST['sales_type'], $_POST['notes']);
$selected_id = $_POST['customer_id'] = db_insert_id();
if (isset($auto_create_branch) && $auto_create_branch == 1) {
add_branch($selected_id, $_POST['CustName'], $_POST['cust_ref'], $_POST['address'], $_POST['salesman'], $_POST['area'], $_POST['tax_group_id'], '', get_company_pref('default_sales_discount_act'), get_company_pref('debtors_act'), get_company_pref('default_prompt_payment_act'), $_POST['location'], $_POST['address'], 0, 0, $_POST['ship_via'], $_POST['notes']);
$selected_branch = db_insert_id();
add_crm_person($_POST['CustName'], $_POST['cust_ref'], '', $_POST['address'], $_POST['phone'], $_POST['phone2'], $_POST['fax'], $_POST['email'], '', '');
add_crm_contact('cust_branch', 'general', $selected_branch, db_insert_id());
}
commit_transaction();
display_notification(_("A new customer has been added."));
if (isset($auto_create_branch) && $auto_create_branch == 1) {
display_notification(_("A default Branch has been automatically created, please check default Branch values by using link below."));
}
$Ajax->activate('_page_body');
}
}