On Wed, 18 Dec 2002, Thorsten Haude wrote:
> Hi,
>
> I want to read an unknown number of rows from a select result. I try
> this:
> - - - Schnipp - - -
> $result = pg_exec($dbh, $statement);
> $row = 0;
> while ($item = pg_fetch_array($result, $row, PGSQL_ASSOC))
> {
> doSomething($item);
> $row++;
> }
> - - - Schnapp - - -
>
> However, I get an error telling me that PHP is "Unable to jump to row
> [$nRows + 1] on PostgreSQL result index 3 in [$file] on line [$line]
Sorry for the previously not quite right response. Since you are passing
in PGSQL_ASSOC you have to supply a row number, do it like this:
$stop = pg_num_rows($result);
for ($i=0;$i<$stop;$i++){
doSomething($item);
}