本文整理汇总了PHP中db_op_result函数的典型用法代码示例。如果您正苦于以下问题:PHP db_op_result函数的具体用法?PHP db_op_result怎么用?PHP db_op_result使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_op_result函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ini_to_db
function ini_to_db($db, $ini_file, $ini_table, $language)
{
// This is a loop, that reads a ini file, of the type variable = value.
// It will loop thru the list of the ini variables, and push them into the db.
$ini_keys = parse_ini_file($ini_file, true);
$status = true;
// This variable allows us to track the inserts into the databse. If one fails, the whole process is considered failed.
$resa = $db->StartTrans();
// We enclose the inserts in a transaction as it is roughly 30 times faster
db_op_result($db, $resa, __LINE__, __FILE__);
foreach ($ini_keys as $config_category => $config_line) {
foreach ($config_line as $config_key => $config_value) {
// We have to ensure that the language string (config_value) is utf8 encoded before sending to the database
$config_value = utf8_encode($config_value);
$debug_query = $db->Execute("INSERT into {$db->prefix}{$ini_table} (name, category, value, language) VALUES (?,?,?,?)", array($config_key, $config_category, $config_value, $language));
db_op_result($db, $debug_query, __LINE__, __FILE__);
if (!$debug_query) {
$status = false;
}
}
}
$trans_status = $db->CompleteTrans();
// Complete the transaction
db_op_result($db, $trans_status, __LINE__, __FILE__);
if ($trans_status && $status) {
return true;
} else {
return false;
}
}
示例2: player_insignia_name
function player_insignia_name($db, $a_username)
{
global $l;
unset($player_insignia);
// Lookup players score.
$res = $db->Execute("SELECT score FROM {$db->prefix}ships WHERE ship_id=?", array($a_username));
db_op_result($db, $res, __LINE__, __FILE__);
$playerinfo = $res->fields;
for ($i = 0; $i < 20; $i++) {
$value = pow(2, $i * 2);
if (!$value) {
// Pow returned false so we need to return an error.
$player_insignia = "<span style='color:#f00;'>ERR</span> [<span style='color:#09f; font-size:12px; cursor:help;' title='Error looking up insignia, please report this error.'>?</span>]";
break;
}
$value *= 500 * 2;
if ($playerinfo['score'] <= $value) {
// Ok we have found our Insignia, now set and break out of the for loop.
$temp_insignia = "l_insignia_" . $i;
$player_insignia = $l->get($temp_insignia);
break;
}
}
if (!isset($player_insignia)) {
// Hmm, player has out ranked out highest rank, so just return that.
$player_insignia = $l->get('l_insignia_19');
}
return $player_insignia;
}
示例3: get_player_name
function get_player_name($userid)
{
global $db, $db_logging;
$query = $db->Execute("SELECT character_name FROM {$db->prefix}ships WHERE ship_id='{$userid}'");
db_op_result($db, $query, __LINE__, __FILE__, $db_logging);
$name = $query->fields;
return $name['character_name'];
}
示例4: xenoberegen
function xenoberegen()
{
global $playerinfo, $xen_unemployment, $xenobeisdead, $db;
// Xenobe Unempoyment Check
$playerinfo['credits'] = $playerinfo['credits'] + $xen_unemployment;
$maxenergy = NUM_ENERGY($playerinfo['power']);
// Regenerate energy
if ($playerinfo['ship_energy'] <= $maxenergy - 50) {
$playerinfo['ship_energy'] = $playerinfo['ship_energy'] + round(($maxenergy - $playerinfo['ship_energy']) / 2);
// Regen half of remaining energy
$gene = "regenerated Energy to {$playerinfo['ship_energy']} units,";
}
$maxarmor = NUM_ARMOR($playerinfo['armor']);
// Regenerate armor
if ($playerinfo['armor_pts'] <= $maxarmor - 50) {
$playerinfo['armor_pts'] = $playerinfo['armor_pts'] + round(($maxarmor - $playerinfo['armor_pts']) / 2);
// Regen half of remaining armor
$gena = "regenerated Armor to {$playerinfo['armor_pts']} points,";
}
// Buy fighters & torpedos at 6 credits per fighter
$available_fighters = NUM_FIGHTERS($playerinfo['computer']) - $playerinfo['ship_fighters'];
if ($playerinfo['credits'] > 5 && $available_fighters > 0) {
if (round($playerinfo['credits'] / 6) > $available_fighters) {
$purchase = $available_fighters * 6;
$playerinfo['credits'] = $playerinfo['credits'] - $purchase;
$playerinfo['ship_fighters'] = $playerinfo['ship_fighters'] + $available_fighters;
$genf = "purchased {$available_fighters} fighters for {$purchase} credits,";
}
if (round($playerinfo['credits'] / 6) <= $available_fighters) {
$purchase = round($playerinfo['credits'] / 6);
$playerinfo['ship_fighters'] = $playerinfo['ship_fighters'] + $purchase;
$genf = "purchased {$purchase} fighters for {$playerinfo['credits']} credits,";
$playerinfo['credits'] = 0;
}
}
// Xenobe pay 3 credits per torpedo
$available_torpedoes = NUM_TORPEDOES($playerinfo['torp_launchers']) - $playerinfo['torps'];
if ($playerinfo['credits'] > 2 && $available_torpedoes > 0) {
if (round($playerinfo['credits'] / 3) > $available_torpedoes) {
$purchase = $available_torpedoes * 3;
$playerinfo['credits'] = $playerinfo['credits'] - $purchase;
$playerinfo['torps'] = $playerinfo['torps'] + $available_torpedoes;
$gent = "purchased {$available_torpedoes} torpedoes for {$purchase} credits,";
}
if (round($playerinfo['credits'] / 3) <= $available_torpedoes) {
$purchase = round($playerinfo['credits'] / 3);
$playerinfo['torps'] = $playerinfo['torps'] + $purchase;
$gent = "purchased {$purchase} torpedoes for {$playerinfo['credits']} credits,";
$playerinfo['credits'] = 0;
}
}
// Update Xenobe record
$resg = $db->Execute("UPDATE {$db->prefix}ships SET ship_energy=?, armor_pts=?, ship_fighters=?, torps=?, credits=? WHERE ship_id=?", array($playerinfo['ship_energy'], $playerinfo['armor_pts'], $playerinfo['ship_fighters'], $playerinfo['torps'], $playerinfo['credits'], $playerinfo['ship_id']));
db_op_result($db, $resg, __LINE__, __FILE__);
if (!$gene == '' || !$gena == '' || !$genf == '' || !$gent == '') {
playerlog($db, $playerinfo[ship_id], LOG_RAW, "Xenobe {$gene} {$gena} {$genf} {$gent} and has been updated.");
}
}
示例5: playerlog
function playerlog($db, $sid, $log_type, $data = "")
{
$data = addslashes($data);
// Write log_entry to the player's log - identified by player's ship_id - sid.
if ($sid != "" && !empty($log_type)) {
$resa = $db->Execute("INSERT INTO {$db->prefix}logs VALUES(NULL, ?, ?, NOW(), ?)", array($sid, $log_type, $data));
db_op_result($db, $resa, __LINE__, __FILE__);
}
}
示例6: message_defence_owner
function message_defence_owner($db, $sector, $message)
{
$result3 = $db->Execute("SELECT * FROM {$db->prefix}sector_defence WHERE sector_id=?", array($sector));
db_op_result($db, $result3, __LINE__, __FILE__);
if ($result3 instanceof ADORecordSet) {
while (!$result3->EOF) {
playerlog($db, $result3->fields['ship_id'], LOG_RAW, $message);
$result3->MoveNext();
}
}
}
示例7: get_player
function get_player($db, $ship_id)
{
global $db_logging;
$res = $db->Execute("SELECT character_name FROM {$db->prefix}ships WHERE ship_id = ?;", array($ship_id));
db_op_result($db, $res, __LINE__, __FILE__, $db_logging);
if ($res) {
$row = $res->fields;
$character_name = $row['character_name'];
return $character_name;
} else {
return "Unknown";
}
}
示例8: adminlog
function adminlog($db, $log_type, $data = "")
{
// Write log_entry to the admin log
$ret = (bool) false;
$data = addslashes($data);
if (!empty($log_type)) {
$ret = $db->Execute("INSERT INTO {$db->prefix}logs VALUES (NULL, 0, ?, NOW(), ?)", array($log_type, $data));
db_op_result($db, $ret, __LINE__, __FILE__);
}
if (!$ret) {
return (bool) false;
} else {
return (bool) true;
}
}
示例9: db_kill_player
function db_kill_player($ship_id, $remove_planets = false)
{
global $default_prod_ore;
global $default_prod_organics;
global $default_prod_goods;
global $default_prod_energy;
global $default_prod_fighters;
global $default_prod_torp;
global $db, $l;
$resa = $db->Execute("UPDATE {$db->prefix}ships SET ship_destroyed='Y', on_planet='N', sector=0, cleared_defences=' ' WHERE ship_id=?", array($ship_id));
db_op_result($db, $resa, __LINE__, __FILE__);
$resb = $db->Execute("DELETE FROM {$db->prefix}bounty WHERE placed_by = ?", array($ship_id));
db_op_result($db, $resb, __LINE__, __FILE__);
$res = $db->Execute("SELECT DISTINCT sector_id FROM {$db->prefix}planets WHERE owner=? AND base='Y'", array($ship_id));
db_op_result($db, $res, __LINE__, __FILE__);
$i = 0;
while (!$res->EOF && $res) {
$sectors[$i] = $res->fields['sector_id'];
$i++;
$res->MoveNext();
}
if ($remove_planets == true && $ship_id > 0) {
$resc = $db->Execute("DELETE FROM {$db->prefix}planets WHERE owner = ?", array($ship_id));
db_op_result($db, $resc, __LINE__, __FILE__);
} else {
$resd = $db->Execute("UPDATE {$db->prefix}planets SET owner=0, corp=0, fighters=0, base='N' WHERE owner=?", array($ship_id));
db_op_result($db, $resd, __LINE__, __FILE__);
}
if (!empty($sectors)) {
foreach ($sectors as $sector) {
calc_ownership($sector);
}
}
$rese = $db->Execute("DELETE FROM {$db->prefix}sector_defence WHERE ship_id=?", array($ship_id));
db_op_result($db, $rese, __LINE__, __FILE__);
$res = $db->Execute("SELECT zone_id FROM {$db->prefix}zones WHERE corp_zone='N' AND owner=?", array($ship_id));
db_op_result($db, $res, __LINE__, __FILE__);
$zone = $res->fields;
$resf = $db->Execute("UPDATE {$db->prefix}universe SET zone_id=1 WHERE zone_id=?", array($zone['zone_id']));
db_op_result($db, $resf, __LINE__, __FILE__);
$query = $db->Execute("SELECT character_name FROM {$db->prefix}ships WHERE ship_id=?", array($ship_id));
db_op_result($db, $query, __LINE__, __FILE__);
$name = $query->fields;
$headline = $name['character_name'] . $l->get('l_killheadline');
$newstext = str_replace("[name]", $name['character_name'], $l->get('l_news_killed'));
$news = $db->Execute("INSERT INTO {$db->prefix}news (headline, newstext, user_id, date, news_type) VALUES (?,?,?,NOW(), 'killed')", array($headline, $newstext, $ship_id));
db_op_result($db, $news, __LINE__, __FILE__);
}
示例10: get_planet_owner_information
function get_planet_owner_information($db = null, $planetID = null, &$ownerInfo = null)
{
$ownerInfo = null;
if (!is_null($planetID) && is_numeric($planetID) && $planetID > 0) {
$sql = "SELECT ship_id, character_name, team FROM {$db->prefix}planets ";
$sql .= "LEFT JOIN {$db->prefix}ships ON {$db->prefix}ships.ship_id = {$db->prefix}planets.owner ";
$sql .= "WHERE {$db->prefix}planets.planet_id=?;";
$res = $db->Execute($sql, array($planetID));
db_op_result($db, $res, __LINE__, __FILE__);
if ($res->RecordCount() > 0) {
$ownerInfo = (array) $res->fields;
return true;
}
}
return false;
}
示例11: get
public function get($langvar = null)
{
// Reach out and grab the global db and language variables (so we don't have to pass them in every language string echo)
global $db, $lang;
// Sanity checking to ensure everything exists before we waste an SQL call
if (is_null($db) || is_null($lang) || is_null($langvar)) {
return false;
}
// Do a cached select from the database and return the value of the language variable requested
$result = $db->CacheExecute(7200, "SELECT name, value FROM {$db->prefix}languages WHERE name=? AND language=?;", array($langvar, $lang));
db_op_result($db, $result, __LINE__, __FILE__);
if ($result && !$result->EOF) {
$row = $result->fields;
return $row['value'];
}
}
示例12: distribute_toll
function distribute_toll($db, $sector, $toll, $total_fighters)
{
$result3 = $db->Execute("SELECT * FROM {$db->prefix}sector_defence WHERE sector_id=? AND defence_type ='F'", array($sector));
db_op_result($db, $result3, __LINE__, __FILE__);
// Put the defence information into the array "defenceinfo"
if ($result3 > 0) {
while (!$result3->EOF) {
$row = $result3->fields;
$toll_amount = ROUND($row['quantity'] / $total_fighters * $toll);
$resa = $db->Execute("UPDATE {$db->prefix}ships SET credits=credits + ? WHERE ship_id = ?", array($toll_amount, $row['ship_id']));
db_op_result($db, $resa, __LINE__, __FILE__);
playerlog($db, $row['ship_id'], LOG_TOLL_RECV, "{$toll_amount}|{$sector}");
$result3->MoveNext();
}
}
}
示例13: cancel_bounty
function cancel_bounty($db, $bounty_on)
{
$res = $db->Execute("SELECT * FROM {$db->prefix}bounty,{$db->prefix}ships WHERE bounty_on = ? AND bounty_on = ship_id", array($bounty_on));
db_op_result($db, $res, __LINE__, __FILE__);
if ($res) {
while (!$res->EOF) {
$bountydetails = $res->fields;
if ($bountydetails['placed_by'] != 0) {
$update = $db->Execute("UPDATE {$db->prefix}ships SET credits = credits + ? WHERE ship_id = ?", array($bountydetails['amount'], $bountydetails['placed_by']));
db_op_result($db, $update, __LINE__, __FILE__);
playerlog($db, $bountydetails['placed_by'], LOG_BOUNTY_CANCELLED, "{$bountydetails['amount']}|{$bountydetails['character_name']}");
}
$delete = $db->Execute("DELETE FROM {$db->prefix}bounty WHERE bounty_id = ?", array($bountydetails['bounty_id']));
db_op_result($db, $delete, __LINE__, __FILE__);
$res->MoveNext();
}
}
}
示例14: defence_vs_defence
function defence_vs_defence($db, $ship_id)
{
global $l;
$result1 = $db->Execute("SELECT * FROM {$db->prefix}sector_defence WHERE ship_id = ?;", array($ship_id));
db_op_result($db, $result1, __LINE__, __FILE__);
if ($result1 instanceof ADORecordSet) {
while (!$result1->EOF) {
$row = $result1->fields;
$deftype = $row['defence_type'] == 'F' ? 'Fighters' : 'Mines';
$qty = $row['quantity'];
$result2 = $db->Execute("SELECT * FROM {$db->prefix}sector_defence WHERE sector_id = ? AND ship_id <> ? ORDER BY quantity DESC", array($row['sector_id'], $ship_id));
db_op_result($db, $result2, __LINE__, __FILE__);
if ($result2 instanceof ADORecordSet) {
while (!$result2->EOF && $qty > 0) {
$cur = $result2->fields;
$targetdeftype = $cur['defence_type'] == 'F' ? $l->get('l_fighters') : $l->get('l_mines');
if ($qty > $cur['quantity']) {
$resa = $db->Execute("DELETE FROM {$db->prefix}sector_defence WHERE defence_id = ?", array($cur['defence_id']));
db_op_result($db, $resa, __LINE__, __FILE__);
$qty -= $cur['quantity'];
$resb = $db->Execute("UPDATE {$db->prefix}sector_defence SET quantity = ? WHERE defence_id = ?", array($qty, $row['defence_id']));
db_op_result($db, $resb, __LINE__, __FILE__);
playerlog($db, $cur['ship_id'], LOG_DEFS_DESTROYED, $cur['quantity'] . "|" . $targetdeftype . "|" . $row['sector_id']);
playerlog($db, $row['ship_id'], LOG_DEFS_DESTROYED, $cur['quantity'] . "|" . $deftype . "|" . $row['sector_id']);
} else {
$resc = $db->Execute("DELETE FROM {$db->prefix}sector_defence WHERE defence_id = ?", array($row['defence_id']));
db_op_result($db, $resc, __LINE__, __FILE__);
$resd = $db->Execute("UPDATE {$db->prefix}sector_defence SET quantity=quantity - ? WHERE defence_id = ?", array($qty, $cur['defence_id']));
db_op_result($db, $resd, __LINE__, __FILE__);
playerlog($db, $cur['ship_id'], LOG_DEFS_DESTROYED, $qty . "|" . $targetdeftype . "|" . $row['sector_id']);
playerlog($db, $row['ship_id'], LOG_DEFS_DESTROYED, $qty . "|" . $deftype . "|" . $row['sector_id']);
$qty = 0;
}
$result2->MoveNext();
}
}
$result1->MoveNext();
}
$rese = $db->Execute("DELETE FROM {$db->prefix}sector_defence WHERE quantity <= 0");
db_op_result($db, $rese, __LINE__, __FILE__);
}
}
示例15: is_loan_pending
function is_loan_pending($db, $ship_id)
{
global $IGB_lrate;
$res = $db->Execute("SELECT loan, UNIX_TIMESTAMP(loantime) AS time FROM {$db->prefix}ibank_accounts WHERE ship_id=?", array($ship_id));
db_op_result($db, $res, __LINE__, __FILE__);
if ($res) {
$account = $res->fields;
if ($account['loan'] == 0) {
return false;
}
$curtime = time();
$difftime = ($curtime - $account['time']) / 60;
if ($difftime > $IGB_lrate) {
return true;
} else {
return false;
}
} else {
return false;
}
}