当前位置: 首页>>代码示例>>PHP>>正文


PHP query_item函数代码示例

本文整理汇总了PHP中query_item函数的典型用法代码示例。如果您正苦于以下问题:PHP query_item函数的具体用法?PHP query_item怎么用?PHP query_item使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了query_item函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 public function index()
 {
     $request = RequestWrapper::$request;
     $target = $request->get('player');
     $target_id = $request->get('player_id');
     if ($target_id) {
         $target_player_obj = Player::find($target_id);
     } else {
         $target_player_obj = Player::findByName($target);
     }
     if ($target_player_obj === null) {
         $template = 'no-player.tpl';
         $viewed_name_for_title = null;
         $parts = array();
     } else {
         $attack_error = 'You must become a ninja first.';
         $clan = Clan::findByMember($target_player_obj);
         $combat_skills = null;
         $display_clan_options = false;
         $items = null;
         $same_clan = false;
         $self = false;
         $targeted_skills = null;
         $template = 'player.tpl';
         $viewed_name_for_title = $target_player_obj->name();
         $viewing_player_obj = Player::find(SessionFactory::getSession()->get('player_id'));
         $kills_today = query_item('SELECT sum(killpoints) FROM levelling_log WHERE _player_id = :player_id AND killsdate = CURRENT_DATE AND killpoints > 0', [':player_id' => $target_player_obj->id()]);
         $rank_spot = query_item('SELECT rank_id FROM rankings WHERE player_id = :player_id limit 1', [':player_id' => $target_player_obj->id()]);
         if ($viewing_player_obj !== null) {
             $viewers_clan = Clan::findByMember($viewing_player_obj);
             $self = $viewing_player_obj->id() === $target_player_obj->id();
             $params = ['required_turns' => 0, 'ignores_stealth' => true];
             $AttackLegal = new AttackLegal($viewing_player_obj, $target_player_obj, $params);
             $AttackLegal->check(false);
             $attack_error = $AttackLegal->getError();
             if (!$attack_error && !$self) {
                 // They're not dead or otherwise unattackable.
                 // Pull the items and some necessary data about them.
                 $inventory = new Inventory($viewing_player_obj);
                 $items = $inventory->counts();
                 $skillDAO = new SkillDAO();
                 if (!$viewing_player_obj->isAdmin()) {
                     $combat_skills = $skillDAO->getSkillsByTypeAndClass($viewing_player_obj->_class_id, 'combat', $viewing_player_obj->level);
                     $targeted_skills = $skillDAO->getSkillsByTypeAndClass($viewing_player_obj->_class_id, 'targeted', $viewing_player_obj->level);
                 } else {
                     $combat_skills = $skillDAO->all('combat');
                     $targeted_skills = $skillDAO->all('targeted');
                 }
             }
             if ($clan && $viewers_clan) {
                 $same_clan = $clan->id == $viewers_clan->id;
                 $display_clan_options = !$self && $same_clan && $viewing_player_obj->isClanLeader();
             }
         }
         $parts = ['viewing_player_obj' => $viewing_player_obj, 'target_player_obj' => $target_player_obj, 'combat_skills' => $combat_skills, 'targeted_skills' => $targeted_skills, 'self' => $self, 'rank_spot' => $rank_spot, 'kills_today' => $kills_today, 'status_list' => Player::getStatusList($target_player_obj->id()), 'clan' => $clan, 'items' => $items, 'account' => Account::findByChar($target_player_obj), 'same_clan' => $same_clan, 'display_clan_options' => $display_clan_options, 'attack_error' => $attack_error];
     }
     $parts['authenticated'] = SessionFactory::getSession()->get('authenticated', false);
     $title = 'Ninja' . ($viewed_name_for_title ? ": {$viewed_name_for_title}" : ' Profile');
     return new StreamedViewResponse($title, $template, $parts, ['quickstat' => 'player']);
 }
开发者ID:BitLucid,项目名称:ninjawars,代码行数:60,代码来源:PlayerController.php

示例2: createAccount

 public static function createAccount($ninja_name, $email, $class_identity)
 {
     $found = Player::findByName($ninja_name);
     if ($found) {
         throw new Exception("Test user found [{$found}] with name [{$ninja_name}] already exists");
     }
     $ip = isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1';
     // Create test user, unconfirmed, whatever the default is for activity.
     $confirm = rand(1000, 9999);
     //generate confirmation code
     $class_id = query_item('SELECT class_id FROM class WHERE identity = :class_identity', [':class_identity' => $class_identity]);
     $ninja = new Player();
     $ninja->uname = $ninja_name;
     $ninja->verification_number = $confirm;
     $ninja->active = 1;
     $ninja->_class_id = $class_id;
     $ninja->save();
     Account::create($ninja->id(), $email, TestAccountCreateAndDestroy::$test_password, $confirm, 0, 1, $ip);
     if ($confirm) {
         $ninja->active = 1;
         $ninja->save();
         $account = Account::findByChar($ninja);
         $account->confirmed = 1;
         $account->setOperational(true);
         $account->save();
     }
     return $ninja->id();
 }
开发者ID:BitLucid,项目名称:ninjawars,代码行数:28,代码来源:TestAccountCreateAndDestroy.php

示例3: testAddShouldIncreaseItemCount

 public function testAddShouldIncreaseItemCount()
 {
     $inventory = new Inventory($this->char);
     $inventory->add('shuriken', 10);
     $count = query_item('select amount from inventory join item on item.item_id = inventory.item_type where owner = :id', [':id' => $this->char->id()]);
     $this->assertEquals(10, $count);
 }
开发者ID:BitLucid,项目名称:ninjawars,代码行数:7,代码来源:InventoryTest.php

示例4: testNonexistentPlayerReturnsNullViaStaticFind

 public function testNonexistentPlayerReturnsNullViaStaticFind()
 {
     $id = query_item('select max(player_id) from players');
     $bad_id = $id + 100;
     $char = Player::find($bad_id);
     $this->assertEquals(null, $char);
 }
开发者ID:BitLucid,项目名称:ninjawars,代码行数:7,代码来源:CharacterTest.php

示例5: testViewNonexistentClan

 public function testViewNonexistentClan()
 {
     $bad_id = query_item('SELECT max(clan_id)+1 AS bad_id FROM clan');
     $request = Request::create('/clan/view', 'GET', ['clan_id' => $bad_id]);
     RequestWrapper::inject($request);
     $response = $this->controller->view($this->m_dependencies);
     $this->assertInstanceOf(StreamedViewResponse::class, $response);
 }
开发者ID:BitLucid,项目名称:ninjawars,代码行数:8,代码来源:ClanControllerTest.php

示例6: testRetrieveCreatedPasswordReset

 /**
  * Retrieve the password request with the appropriate nonce data
  *
  * @group early
  */
 public function testRetrieveCreatedPasswordReset()
 {
     $account_id = query_item('select account_id from accounts limit 1');
     $this->assertGreaterThan(0, $account_id);
     $this->nonce = '777777';
     $req = PasswordResetRequest::generate(new Account($account_id), $this->nonce);
     $this->assertEquals($this->nonce, $req->nonce);
     // Create
     $req = PasswordResetRequest::match($this->nonce);
     // Match
     $this->assertEquals($this->nonce, $req->nonce);
 }
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:17,代码来源:PasswordResetTest.php

示例7: setUp

 function setUp()
 {
     $clan_identity = 'randomNewTestClan';
     $id_already_exists = query_item('select clan_id from clan where clan_name = :name', [':name' => $clan_identity]);
     if ($id_already_exists) {
         $this->deleteClan($id_already_exists);
     }
     $this->clan = ClanFactory::create($clan_identity, ['founder' => 'phpunittest', 'description' => 'Some clan description']);
     $this->clan_id = $this->clan->getId();
     $this->char_id = TestAccountCreateAndDestroy::char_id();
     $this->char_id_2 = TestAccountCreateAndDestroy::char_id_2();
 }
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:12,代码来源:ClanTest.php

示例8: membershipAndCombatStats

 /**
  * Stats on recent activity and other aggregate counts/information.
  *
  * @return array
  */
 private function membershipAndCombatStats()
 {
     DatabaseConnection::getInstance();
     $viciousResult = DatabaseConnection::$pdo->query('SELECT stat_result from past_stats where id = 4');
     $todaysViciousKiller = $viciousResult->fetchColumn();
     $stats = [];
     $stats['vicious_killer'] = $todaysViciousKiller;
     $playerCount = DatabaseConnection::$pdo->query("SELECT count(player_id) FROM players WHERE active = 1");
     $stats['player_count'] = $playerCount->fetchColumn();
     $stats['active_chars'] = query_item("SELECT count(*) FROM ppl_online WHERE member = true AND activity > (now() - CAST('15 minutes' AS interval))");
     return $stats;
 }
开发者ID:BitLucid,项目名称:ninjawars,代码行数:17,代码来源:RumorController.php

示例9: get_char_id

/**
 * Return the char id that corresponds with a char name, or the logged in account, if no other source is available.
 *
 * @return int|null
 */
function get_char_id($p_name)
{
    $sql = "SELECT player_id FROM players WHERE lower(uname) = :find";
    return query_item($sql, array(':find' => strtolower($p_name)));
}
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:10,代码来源:lib_auth.php

示例10: get_gold

function get_gold($char_id)
{
    return (int) query_item('SELECT gold FROM players WHERE player_id = :char_id', array(':char_id' => $char_id));
}
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:4,代码来源:lib_inventory.php

示例11: class_display_name_from_identity

function class_display_name_from_identity($identity)
{
    return query_item('SELECT class_name from class where identity = :identity', array(':identity' => $identity));
}
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:4,代码来源:lib_accounts.php

示例12: check

 /**
  * Checks whether an attack is legal or not.
  *
  * @return boolean
  **/
 public function check($update_timer = true)
 {
     $attacker = $this->attacker;
     $target = $this->target;
     $possible = array('required_turns', 'ignores_stealth', 'self_use', 'clan_forbidden');
     // *** Initializes all the possible param indexes. ***
     foreach ($possible as $loop_index) {
         ${$loop_index} = isset($this->params[$loop_index]) ? $this->params[$loop_index] : NULL;
     }
     if (!is_object($this->attacker)) {
         $this->error = 'Only Ninja can get close enough to attack.';
         return FALSE;
     } elseif (!is_object($this->target)) {
         $this->error = 'No valid target was found.';
         return FALSE;
     } elseif (!isset($this->params['required_turns'])) {
         $this->error = 'The required number of turns was not specified.';
         return FALSE;
     }
     $second_interval_limiter_on_attacks = '.25';
     // Originally .2
     $sel_last_started_attack = "SELECT player_id FROM players\n\t\t\tWHERE player_id = :char_id\n\t\t\tAND ((now() - :interval::interval) >= last_started_attack) LIMIT 1";
     // *** Returns a player id if the enough time has passed, or else or false/null. ***
     $attack_later_than_limit = query_item($sel_last_started_attack, array(':char_id' => intval($this->attacker->id()), ':interval' => $second_interval_limiter_on_attacks . ' second'));
     if ($attack_later_than_limit && $update_timer) {
         // *** If not too soon, update the attack limit. ***
         update_last_attack_time($attacker->id());
         // updates the timestamp of the last_attacked column to slow excessive attacks.
     }
     //  *** START OF ILLEGAL ATTACK ERROR LIST  ***
     if (!$attack_later_than_limit) {
         $this->error = 'Even the fastest ninja cannot act more than four times a second.';
     } else {
         if (empty($target->vo->uname)) {
             $this->error = 'Your target does not exist.';
         } else {
             if ($target->id() == $attacker->id() && !$self_use) {
                 $this->error = 'Commiting suicide is a tactic reserved for samurai.';
             } else {
                 if ($attacker->vo->turns < $required_turns) {
                     $this->error = 'You don\'t have enough turns for that, wait for the half hour or use amanita mushrooms to gain more turns.';
                 } else {
                     if (!$self_use && $this->sameDomain($target, $attacker)) {
                         $this->error = 'You can not attack a ninja from the same domain.';
                     } else {
                         if ($target->vo->active == 0) {
                             $this->error = 'You can not attack an inactive ninja.';
                         } else {
                             if ($attacker->vo->active == 0) {
                                 $this->error = 'You cannot attack when your ninja is retired/inactive.';
                             } else {
                                 if ($target->health() < 1) {
                                     $this->error = "They're already dead.";
                                 } else {
                                     if ($target->hasStatus(STEALTH) && !$ignores_stealth) {
                                         // Attacks that ignore stealth will skip this.
                                         $this->error = 'Your target is stealthed. You can only hit this ninja using certain techniques.';
                                     } else {
                                         if ($clan_forbidden && $target->getClan()->getID() == $attacker->getClan()->getID() && $attacker->getClan() == null && !$self_use) {
                                             $this->error = 'Your clan would outcast you if you attacked one of your own.';
                                         } else {
                                             if ($target->health() > 0) {
                                                 $this->error = null;
                                                 return true;
                                                 //  ***  ATTACK IS LEGAL ***
                                             } else {
                                                 //  *** CATCHALL ERROR MESSAGE ***
                                                 $this->error = 'There was a problem with your attack.';
                                                 error_log('The problem catch-all for attackLegal object was triggered, which should not occur.');
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return empty($this->error);
 }
开发者ID:reillo,项目名称:ninjawars,代码行数:87,代码来源:AttackLegal.class.php

示例13: changeKills

 /**
  * Change the kills amount of a char, and levels them up when necessary.
  * @return int
  */
 private function changeKills($amount)
 {
     $amount = (int) $amount;
     GameLog::updateLevellingLog($this->id(), $amount);
     if ($amount !== 0) {
         // Ignore changes that amount to zero.
         if ($amount > 0) {
             // when adding kills, check if levelling occurs
             $this->levelUp();
         }
         query("UPDATE players SET kills = kills + CASE WHEN kills + :amount1 < 0 THEN kills*(-1) ELSE :amount2 END WHERE player_id = :player_id", [':amount1' => [$amount, PDO::PARAM_INT], ':amount2' => [$amount, PDO::PARAM_INT], ':player_id' => $this->id()]);
     }
     return $this->vo->kills = query_item("SELECT kills FROM players WHERE player_id = :player_id", [':player_id' => [$this->id(), PDO::PARAM_INT]]);
 }
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:18,代码来源:Player.class.php

示例14: membership_and_combat_stats

function membership_and_combat_stats($update_past_stats = false)
{
    DatabaseConnection::getInstance();
    $vk = DatabaseConnection::$pdo->query('SELECT stat_result from past_stats where id = 4');
    $todaysViciousKiller = $vk->fetchColumn();
    $stats['vicious_killer'] = $todaysViciousKiller;
    $pc = DatabaseConnection::$pdo->query("SELECT count(player_id) FROM players WHERE active = 1");
    $stats['player_count'] = $pc->fetchColumn();
    $po = DatabaseConnection::$pdo->query("SELECT count(*) FROM ppl_online WHERE member = true");
    $stats['players_online'] = $po->fetchColumn();
    $stats['active_chars'] = query_item("SELECT count(*) FROM ppl_online WHERE member = true AND activity > (now() - CAST('15 minutes' AS interval))");
    return $stats;
}
开发者ID:reillo,项目名称:ninjawars,代码行数:13,代码来源:lib_auth.php

示例15: self_char_id

     $covert = true;
     $state = 'stealthed';
     if (!$target->hasStatus(STEALTH)) {
         $target->addStatus(STEALTH);
         $generic_state_change = "__TARGET__ is now {$state}.";
     } else {
         $turn_cost = 0;
         $generic_state_change = "__TARGET__ is already {$state}.";
     }
 } else {
     if ($command == 'Kampo') {
         $covert = true;
         // *** Get Special Items From Inventory ***
         $user_id = self_char_id();
         $root_item_type = 7;
         $itemCount = query_item('SELECT sum(amount) AS c FROM inventory WHERE owner = :owner AND item_type = :type GROUP BY item_type', array(':owner' => $user_id, ':type' => $root_item_type));
         $turn_cost = min($itemCount, $starting_turns - 1, 2);
         // Costs 1 or two depending on the number of items.
         if ($turn_cost && $itemCount > 0) {
             // *** If special item count > 0 ***
             removeItem($user_id, 'ginsengroot', $itemCount);
             add_item($user_id, 'tigersalve', $itemCount);
             $generic_skill_result_message = 'With intense focus you grind the ' . $itemCount . ' roots into potent formulas.';
         } else {
             // *** no special items, give error message ***
             $turn_cost = 0;
             $generic_skill_result_message = 'You do not have the necessary ginsengroots or energy to create any Kampo formulas.';
         }
     } else {
         if ($command == 'Poison Touch') {
             $covert = true;
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:31,代码来源:skills_mod.php


注:本文中的query_item函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。