Re: Cursors and PHP

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Cursors and PHP
Дата
Msg-id 10708.1082218679@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Cursors and PHP  (Steve Manes <smanes@magpie.com>)
Ответы Re: Cursors and PHP  (Steve Manes <smanes@magpie.com>)
Список pgsql-general
Steve Manes <smanes@magpie.com> writes:
>      $query = "SELECT get_user_data('$cursor', $user_id);FETCH ALL IN
> $cursor;";

>      $res =& $dbh->query($query);

Hm.  This will return two different, not-compatible result sets (the
SELECT's output and then the FETCH's).  I don't know how PHP is defined
to react to that.  It seems that it's just discarding the first result
set and giving you the second, but is that specified behavior or is it
a bug that may get fixed someday?  Might be best to do this in two
queries.

> Question #2: I'm using a persistent database connection.  To avoid
> leaving an open cursor laying around I make another call to close the
> cursor after the result set is fetched.  Do I need to do this or will
> the cursor be closed implicitly by Apache/PHP after the page is delivered?

The backend will implicitly close the cursor at transaction end.  If the
connection-pooling code is set up to issue a COMMIT after the page is
processed, you need not close the cursor separately.

            regards, tom lane

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

Предыдущее
От: Bruno Wolff III
Дата:
Сообщение: Re: build contrib
Следующее
От: Ken Godee
Дата:
Сообщение: Re: Python to postgresql interface