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


PHP Map::push方法代码示例

本文整理汇总了PHP中Map::push方法的典型用法代码示例。如果您正苦于以下问题:PHP Map::push方法的具体用法?PHP Map::push怎么用?PHP Map::push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Map的用法示例。


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

示例1: loadPlayerRelations

 /**
  * Loads the player relations (from buddylist).
  *
  * @return Bengine_Game_User_Relation
  */
 protected function loadPlayerRelations()
 {
     if ($this->playersLoaded) {
         return $this;
     }
     $where = Core::getDB()->quoteInto("accepted = ? AND ", 1);
     $where .= Core::getDB()->quoteInto("(friend1 = ? OR friend2 = ?)", $this->userid);
     $result = Core::getQuery()->select("buddylist", array("friend1", "friend2"), "", $where);
     foreach ($result->fetchAll() as $row) {
         $rel = $row["friend1"] == $this->userid ? $row["friend2"] : $row["friend1"];
         $this->players->push($rel);
     }
     $result->closeCursor();
     $this->playersLoaded = true;
     Hook::event("PlayerRelationsLoaded", array(&$this->players));
     return $this;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:22,代码来源:Relation.php

示例2: loginFailed

 /**
  * Count login attempt up and redirect to login site.
  *
  * @param string $errorid	Error message id
  *
  * @return Login
  */
 protected function loginFailed($errorid)
 {
     $this->errors->push($errorid);
     if ($this->countLoginAttempts) {
         $spec = array("time" => TIME, "ip" => IPADDRESS, "username" => $this->usr);
         Core::getQuery()->insert("loginattempts", $spec);
     }
     if ($this->redirectOnFailure) {
         forwardToLogin($errorid);
     }
     return $this;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:19,代码来源:Login.util.php

示例3: setPicture

 /**
  * Generates picture.
  *
  * @return Bengine_Game_Planet_Creator
  */
 protected function setPicture()
 {
     $planetTypes = new Map();
     $meta = Application::getMeta();
     foreach ($meta["config"]["planet"]["type"] as $name => $planetType) {
         if ($this->position >= $planetType["from"] && $this->position <= $planetType["to"]) {
             $planetTypes->push(array("name" => $name, "number" => $planetType["number"]));
         }
     }
     $randomPlanet = $planetTypes->getRandomElement();
     $this->picture = sprintf("%s%02d", $randomPlanet["name"], mt_rand(1, $randomPlanet["number"]));
     return $this;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:18,代码来源:Creator.php

示例4: test_push_pop

 public function test_push_pop()
 {
     $num1 = rand();
     $num2 = rand();
     $nums = new Map();
     $nums->push($num1);
     $this->assertCount(1, $nums);
     $nums->push($num2);
     $this->assertCount(2, $nums);
     $popped = $nums->pop();
     $this->assertCount(1, $nums);
     $this->assertSame($num2, $popped);
     $popped = $nums->pop();
     $this->assertCount(0, $nums);
     $this->assertSame($num1, $popped);
 }
开发者ID:haldayne,项目名称:boost,代码行数:16,代码来源:MapTest.php


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