php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22042 pg_result_seek($res, 0) sets the counter to 1, not 0
Submitted: 2003-02-04 05:34 UTC Modified: 2003-02-04 12:35 UTC
From: shot at shot dot prv dot pl Assigned:
Status: Closed Package: PostgreSQL related
PHP Version: 4.3.0 OS: Slackware Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: shot at shot dot prv dot pl
New email:
PHP Version: OS:

 

 [2003-02-04 05:34 UTC] shot at shot dot prv dot pl
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' 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-04 12:35 UTC] iliaa@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 08:01:29 2024 UTC