Re: pg_fetch_array()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Hi,

* Harry Waddell <waddell@xxxxxxxxxxx> [2002-12-18 22:12]:
>Thorsten Haude <postgresql@xxxxxxxxxxxxxx> 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


[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux