本文整理汇总了PHP中Game::getID方法的典型用法代码示例。如果您正苦于以下问题:PHP Game::getID方法的具体用法?PHP Game::getID怎么用?PHP Game::getID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game
的用法示例。
在下文中一共展示了Game::getID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructs a GroupRequestQueue with entries matching the specified game and step.
*
* @param Game $game the desired game
* @param Round $round the desired round
*/
public function __construct(Game $game, Round $round)
{
$this->requests = array();
$dbh = Database::handle();
$sth = $dbh->prepare('SELECT * FROM group_requests WHERE game = :game AND step = :step');
$sth->bindValue(':game', $game->getID());
$sth->bindValue(':step', strval($round));
$sth->execute();
while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
$expires = Util::sql2unixtime($row['expires']);
if ($expires == 0) {
$expires = NULL;
}
$this->requests[] = new GroupRequest(Session::fromSessionID($row['session']), $expires);
}
}
示例2: getGroup
/** @deprecated */
public static function getGroup(Game $game, $step, Session $session)
{
$dbh = Database::handle();
// find all groups with this game and step
$sth = $dbh->prepare('SELECT * FROM groups WHERE game = :game AND step = :step');
$sth->bindValue(':game', $game->getID());
$sth->bindValue(':step', $step);
$sth->execute();
// find one that contains this session
while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
$session_ids = unserialize($row['sessions']);
if (in_array($session->id, $session_ids)) {
// use it to construct the group
$sessions = array_map(function ($session_id) {
return Session::fromSessionID($session_id);
}, $session_ids);
return new Group($row['id'], $sessions, unserialize($row['data']));
}
}
// couldn't find anything!
throw new Exception('could not find group with matching game, step, and session');
}
示例3: fromAssignmentID
/**
* Returns the session identified by the given assignment id.
*
* @param string $assignment_id the AMT assignment ID, a unique ID given by Amazon to each assignment
* @param Game $game the game associated with this assignment (should be known because HitId is also passed)
* @throws DoesNotExistException if there is no session with this assignment ID and game
*/
public static function fromAssignmentID($assignment_id, Game $game)
{
$game_id = $game->getID();
$dbh = Database::handle();
$sth = $dbh->prepare('SELECT session_id FROM sessions WHERE assignment_id = ? AND game = ?');
$sth->execute(array($assignment_id, $game_id));
if ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
$session_id = $row['session_id'];
return self::fromSessionID($session_id);
} else {
throw new DoesNotExistException('unknown assignment id');
}
}