Re: Cursors and PHP

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Steve Manes <smanes(at)magpie(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Cursors and PHP
Date: 2004-04-17 16:17:59
Message-ID: 10708.1082218679@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Steve Manes <smanes(at)magpie(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ken Godee 2004-04-17 16:19:36 Re: Python to postgresql interface
Previous Message Bruno Wolff III 2004-04-17 15:42:20 Re: build contrib