From:             [EMAIL PROTECTED]
Operating system: Slackware Linux
PHP version:      4.3.0
PHP Bug Type:     PostgreSQL related
Bug description:  pg_result_seek($res, 0) sets the counter to 1, not 0

If I get the idea of pg_result_seek() right, instead of the following
script

$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
    }
}

I should be able to write

$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.

PostgreSQL 7.2.3 on i686-pc-linux-gnu, compiled by GCC egcs-2.91.66

Configure Command  './configure' '--with-pgsql=/usr/local/pgsql'
'--with-pdflib=/usr/local' '--with-swf'
'--with-apxs=/usr/local/apache/bin/apxs' '--enable-magic-quotes'
'--disable-track-vars' '--without-mysql' '--with-zlib'
'--with-openssl=/usr/local/ssl'
'--with-mnogosearch=/usr/local/mnogosearch' '--enable-sigchild'
'--enable-inline-optimization' '--with-jpeg-dir=/usr/lib'
'--with-png-dir=/usr/lib' '--with-tiff-dir=/usr/lib' '--with-pear'
'--with-gd' '--with-iconv' '--with-imap' 
-- 
Edit bug report at http://bugs.php.net/?id=22042&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=22042&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=22042&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=22042&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=22042&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=22042&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=22042&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=22042&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=22042&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=22042&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=22042&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=22042&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=22042&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=22042&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=22042&r=gnused

Reply via email to