我想知道如何創建預準備語句。我現在有這樣的:我可以在相同的準備語句中將等於或不等於
$stmt = $mysqli->stmt_init();
if($stmt->prepare("SELECT fk_player_id, player_draws, player_turn, player_passes, swapped FROM ".$prefix."_gameplayer WHERE fk_game_id = ? AND fk_player_id = ?")){
$stmt->bind_param('ii', $currgame, $playerid);
$stmt->execute();
$stmt->bind_result($playerid, $udraws, $uturn, $upass, $uswaps);
$stmt->fetch();
// HERE I WANT TO MAKE A NEW CALL //
$stmt->close();
}
在區域//這裏我要做出新的呼叫//我想運行此:
$sql = mysql_query("SELECT fk_player_id, player_tiles, player_draws, player_turn, player_passes, swapped FROM ".$prefix."_gameplayer WHERE fk_game_id = $currgame AND fk_player_id != $playerid");
$row = mysql_fetch_assoc($sql);
$opponent = $row['fk_player_id'];
$oppTiles = $row['player_tiles'];
$odraws = $row['player_draws']+1;
$oturn = $row['player_turn'];
$opass = $row['player_passes'];
$oswaps = $row['swapped'];
汀是taht 2個電話是除了=和!=以外。這可以在同一個陳述中完成嗎?
在此先感謝:-)
沒有使用相同的語句,但如果這是在試圖減少額外的數據庫查詢,你可以只得到所有的結果在一個(離開了'共fk_player_id')聲明並手動分割結果。 – RayViljoen
爲什麼你在第二個代碼部分使用'mysql_ *'函數?它們已被棄用,並且您沒有正確地轉義查詢參數。 –