-1

クエリの結果を数回ループする必要があります。最初のループの後、ポインターが一番下にあるため、結果を再度確認することはできません。トップに戻すにはどうしたらいいですか?より多くのリソースを使用して同じ結果を返すだけなので、クエリを再度実行したくありません。

$stmt = $conn->prepare("SELECT * FROM customers");
$stmt->setFetchMode(PDO::FETCH_ASSOC);
$stmt->execute();

//This kind of loop will repeat elsewhere in the code
while($row = $stmt->fetch()){ 
//Do something here
}
4

1 に答える 1

2
while($row = $stmt->fetch()){ 
    $rows[] = $row;  //use $rows later
    //Do something here with $row
}
于 2013-10-11T21:08:32.540 に答える