Hello.
I have a problem with the newly introduced pg_result_seek() function.
Until PHP 4.3.0, when I had to iterate through one pg_query result many
times, I used the for loop:
$result = pg_query($db, $query);
// some outside loop
while ($whatever) {
for ($i = 0; $i < pg_num_rows($result); $i++) {
$row = pg_fetch_array($result, $i);
// do something
}
}
Now, with PHP 4.3.0, I'd like to use the cleaner pg_result_seek() (along
with the fact that pg_fetch_array() returns FALSE when there are no more
rows) - and I thought I know how:
$result = pg_query($db, $query);
// some outside loop
while ($whatever) {
pg_result_seek($result, 0);
while ($row = pg_fetch_array($result)) {
// do something
}
}
The problem is, when I use it this way, it misses the first row (it
looks like it iterated from the row nr 1, which is the second row in the
result). I even tried to call pg_result_seek($result, -1), but, not
surprisingly, it didn't work.
bugs.php.net doesn't have any entries about pg_result_seek(), so I guess
it must be something wrong with my code. Any ideas? Your help would be
most appreciated, as I'm fighting this since saturday without a clue.
Cheers,
-- Shot
--
No, I'm from Iowa. I only work in outer space.
-- Kirk, "Star Trek IV"
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php