Php 如何倒带pg_fetch_assoc($result,null)迭代器

Php 如何倒带pg_fetch_assoc($result,null)迭代器,php,postgresql,Php,Postgresql,我正在使用pg_fetch_assoc对SQL查询的结果进行迭代,但我需要多次这样做,而且我找不到“倒带”迭代器的方法 while ($record = pg_fetch_assoc($result, null)) { if ($record["position"] == $position_cell) { echo "<strong>J" . $record["order"] . " </strong>"; }; } while($re

我正在使用pg_fetch_assoc对SQL查询的结果进行迭代,但我需要多次这样做,而且我找不到“倒带”迭代器的方法

while ($record = pg_fetch_assoc($result, null)) {
    if ($record["position"] == $position_cell) {
        echo "<strong>J" . $record["order"] . " </strong>";
    };
}
while($record=pg\u fetch\u assoc($result,null)){
如果($record[“position”]==$position\u单元格){
echo“J.”$record[“order”]。“”;
};
}
因此,如果这个$result包含4行,我将迭代其中的4行,但是当我再次执行此代码时,它将什么也不做

我知道我可以用整数而不是空值进行迭代,但是我必须计算行数,我发现这种语法非常方便,所以如果你能告诉我一种方法,那就太好了

非常感谢。

您可以使用

pg_result_seek($result, 0);

我不知道我怎么没找到它。谢谢