Search Postgresql Archives

Re: Cursors and PHP

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

 



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

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux