本文整理匯總了PHP中game::setId方法的典型用法代碼示例。如果您正苦於以下問題:PHP game::setId方法的具體用法?PHP game::setId怎麽用?PHP game::setId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類game
的用法示例。
在下文中一共展示了game::setId方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: save
/**
* Saves an game into the database.
*
* @param \GamyGoody\Domain\game $game The game to save
*/
public function save(game $game)
{
$logo = $game->getLogo();
$bg = $game->getBackground();
$this->imageDAO->save($logo);
$this->imageDAO->save($bg);
$gameData = array('game_title' => $game->getTitle(), 'game_logo_id' => $logo->getId(), 'game_bg_id' => $bg->getId());
if ($game->getId()) {
// The game has already been saved : update it
$this->getDb()->update('game', $gameData, array('game_id' => $game->getId()));
} else {
// The game has never been saved : insert it
$this->getDb()->insert('game', $gameData);
// Get the id of the newly created game and set it on the entity.
$id = $this->getDb()->lastInsertId();
$game->setId($id);
}
}