Re: pg_fetch_array()

Поиск
Список
Период
Сортировка
От Harry Waddell
Тема Re: pg_fetch_array()
Дата
Msg-id 20021218131228.13eb6d7d.waddell@caravan.com
обсуждение исходный текст
Ответ на pg_fetch_array()  (Thorsten Haude <postgresql@thorstenhau.de>)
Ответы Re: pg_fetch_array()  (Thorsten Haude <postgresql@thorstenhau.de>)
Список pgsql-php
On Wed, 18 Dec 2002 21:38:32 +0100
Thorsten Haude <postgresql@thorstenhau.de> 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]
>
> What do I miss?
>

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. 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.

--
Harry Waddell
Caravan Electronic Publishing


В списке pgsql-php по дате отправления:

Предыдущее
От: Ray Hunter
Дата:
Сообщение: Re: problems when i try to connect to my Databasse
Следующее
От: Philipp Ottlinger
Дата:
Сообщение: Re: pg_fetch_array()