本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}