Re: pg_fetch_array()
| От | Thorsten Haude | 
|---|---|
| Тема | Re: pg_fetch_array() | 
| Дата | |
| Msg-id | 20021218220329.GK1604@eumel.yoo.local обсуждение исходный текст  | 
		
| Ответ на | Re: pg_fetch_array() (Harry Waddell <waddell@caravan.com>) | 
| Список | pgsql-php | 
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
		
	В списке pgsql-php по дате отправления: