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