Getting multiple rows with prepared statement

后端 未结 3 1835
梦毁少年i
梦毁少年i 2021-01-05 18:35

I\'m quite new to prepared statements and am not sure I am doing this right.

Here is what I try:

$currgame = 310791;

$sql = \"SELECT fk_player_id, p         


        
3条回答
  •  遥遥无期
    2021-01-05 19:00

    Depending on your PHP/MySQL setup you may not be able to use get_result().

    The way to get around this is to bind the results.

    For example:

    $stmt->execute();
    
    $fk_player_id = null; $player_tiles = null; $player_draws = null; $player_turn = null; $player_passes = null; $swapped = null;
    
    $stmt->bind_result($fk_player_id, $player_tiles, $player_draws, $player_turn, $player_passes, $swapped);
    
    while ($stmt->fetch()) { // For each row
        /* You can then use the variables declared above, which will have the 
        new values from the query every time $stmt->execute() is ran.*/
    }
    

    For more information click here

提交回复
热议问题