pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: scott.marlowe <scott.marlowe@ihs.com>
To: Thorsten Haude <postgresql@thorstenhau.de>
Cc: PostgreSQL PHP ML <pgsql-php@postgresql.org>
Subject: Re: pg_fetch_array()
Date: Wed, 18 Dec 2002 15:04:01 -0700 (MST)
Message-ID: <Pine.LNX.4.33.0212181501190.4045-100000@css120.ihs.com> (raw)
In-Reply-To: <20021218203832.GI1604@eumel.yoo.local>

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);
}




view thread (12+ messages)  latest in thread

Message-ID: <Pine.LNX.4.33.0212181501190.4045-100000@css120.ihs.com>
Permalink:  ../Pine.LNX.4.33.0212181501190.4045-100000@css120.ihs.com/
Also on:    postgresql.org/message-id/Pine.LNX.4.33.0212181501190.4045-100000@css120.ihs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: scott.marlowe@ihs.com, postgresql@thorstenhau.de
  Subject: Re: pg_fetch_array()
  In-Reply-To: <Pine.LNX.4.33.0212181501190.4045-100000@css120.ihs.com>
  References: <20021218203832.GI1604@eumel.yoo.local> <Pine.LNX.4.33.0212181501190.4045-100000@css120.ihs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox