From: Thorsten Haude <postgresql@thorstenhau.de>
To: pgsql-php@postgresql.org
Subject: Re: pg_fetch_array()
Date: Wed, 18 Dec 2002 23:03:29 +0100
Message-ID: <20021218220329.GK1604@eumel.yoo.local> (raw)
In-Reply-To: <20021218131228.13eb6d7d.waddell@caravan.com>
References: <20021218203832.GI1604@eumel.yoo.local>
<20021218131228.13eb6d7d.waddell@caravan.com>
Hi,
* Harry Waddell <waddell@caravan.com> [2002-12-18 22:12]:
>Thorsten Haude <postgresql@thorstenhau.de> wrote:
>> - - - Schnipp - - -
>> $result = pg_exec($dbh, $statement);
>> $row = 0;
>> while ($item = pg_fetch_array($result, $row, PGSQL_ASSOC))
>> {
>> doSomething($item);
>> $row++;
>> }
>> - - - Schnapp - - -
>>
>> What do I miss?
A clue-by-four, it seems.
>your using a while loop to process each result, but the last one which you
>expect to return NULL/failure has to evaluate pg_fetch_array first with the
>non-existent row index.
Of course. The only excuse I have is that I misread the documentation
in a really stupid way. (Not much of an excuse, is it?)
>You may be able to prepend @ to pg_fetch_array to supress the warning
>[you should check that $result is not NULL also], but I'd recommend
>using pg_NumRows and a for-loop instead.
Sure, I'll do that. I don't want to suppress anyone, much less
warnings.
Thanks for your patience.
Thorsten
--
Endorsing products is the American way of expressing individuality.
- Calvin
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: postgresql@thorstenhau.de
Subject: Re: pg_fetch_array()
In-Reply-To: <20021218220329.GK1604@eumel.yoo.local>
References: <20021218203832.GI1604@eumel.yoo.local> <20021218131228.13eb6d7d.waddell@caravan.com> <20021218220329.GK1604@eumel.yoo.local>
* 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