pg_pconnect+PostgreSQL cursors
am 26.12.2002 17:59:14 von Sergei Levchenko
Hi all
$connection = pg_pconnect("dbname=$db user=$user password=$password");
if (!isset($page))
{
pg_exec($connection, "BEGIN WORK");
pg_exec($connection, "DECLARE all_data CURSOR FOR SELECT id,body FROM test")
}
$result = pg_exec($connection, "FETCH 1 FROM all_data");
$info = pg_fetch_array($result, 0);
print "|$info[0]|$info[1]|
\n";
?>
When I execute this script at first without page parameter I'v got data to info array! when I execute it at other times I'v got nothing :(
I've got closing of cursor and transaction! why??? I use permanent connection, why I've got closing of cursor and transaction!???
--
WBR, sector119
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
Re: pg_pconnect+PostgreSQL cursors
am 03.01.2003 05:20:12 von Keary Suska
on 12/26/02 9:59 AM, serg@city.gov.te.ua purportedly said:
> I've got closing of cursor and transaction! why??? I use permanent connection,
> why I've got closing of cursor and transaction!???
The "p" in "pconnect" means *persistent*, not permanent. The connection will
persist after the script has completed, however, the connection is handled
by the web server process and its true lifetime is only the lifetime of the
process. For Apache, this will vary by configuration, and is difficult to
predict when hosting multiple sites.
Tip: persistent connections are only useful when you want (and have the
resources to support) to minimize connection overhead. Any other use and you
are likely to be severely disappointed.
Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org