本文整理匯總了PHP中game::last_inserted_id方法的典型用法代碼示例。如果您正苦於以下問題:PHP game::last_inserted_id方法的具體用法?PHP game::last_inserted_id怎麽用?PHP game::last_inserted_id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類game
的用法示例。
在下文中一共展示了game::last_inserted_id方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: add_new_game
public static function add_new_game($current_turn_player_id, $size, $player1ID, $player2ID)
{
$date = time();
if (safe_input::is_number($current_turn_player_id) && safe_input::is_number($size) && $size > 1 && safe_input::is_number($player1ID) && safe_input::is_number($player2ID) && ($current_turn_player_id == $player1ID || $current_turn_player_id == $player2ID)) {
$db = new database();
$query = "INSERT INTO `game` (`winnerID`, `createDate`, `currentTurnPlayerID`, `size`, `lastActivityDate`, `player1ID` , `player2ID`) VALUES ( null, '{$date}', '{$current_turn_player_id}', '{$size}', null , '{$player1ID}', '{$player2ID}');";
$res = $db->query($query);
game::$last_inserted_id = $db->insert_id();
return $res;
} else {
//echo "table_game::add_new_game: current turn or size or player id is not a number!" ;
return false;
}
}