pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: brew@theMode.com
To: pgsql-php@postgresql.org
Subject: Re: pg_pconnect
Date: Sat, 28 Dec 2002 10:10:33 -0500 (EST)
Message-ID: <Pine.BSF.4.44.0212280948590.8607-100000@themode.com> (raw)
In-Reply-To: <20021227090902.GA2637@city.gov.te.ua>


On Fri, 27 Dec 2002 sector119@mail.ru wrote:

> when I click on next screen link I get db handler does not exist
> anymore! why???

The db handle is only a variable that points at the persistent connection.
Although the database connection is persistent (that is, remains after the
a php script completes) the db handle variable goes away.

You have to again call the pg_pconnect() function before using it in a
following script.

A persistent database connection does not save web page state, the only
thing it does is leave the pipe connected between the web server and the
database server, thereby saving the time of establishing a new connection.
The only benefit is speed.

You mostly write the PHP script exactly the same using either pg_pconnect
or pg_connect (except you have to be careful of hanging transactions
tieing up your persistent connections).  I think you would be better off
using pg_connect for development and consider changing to persistent
connections later.

Read Chapter 21 in the manual at php.net entitled Persistent Database
Connections.

later.... brew

> Hi
>
> <?
> echo "<html><body>\n";
> $db = pg_pconnect("dbname=$dbname user=$user password=$dbpassword");
> if (!$db)
> echo "Connection can not be established!<br>\n";
> else
> echo "Connection established!<br>\n";
> echo "<a href=\"cursor4.php\">next screen</a><br>";
> echo "</body></html>";
> ?>
>
> <?
> echo "<html><body>\n";
> if ($db)
> echo "db handler is still valid!<br>\n";
> else
> echo "db handler does not exist anymore!<br>\n";
> echo "</body></html>";
> ?>
>
>





view thread (26+ messages)

Message-ID: <Pine.BSF.4.44.0212280948590.8607-100000@themode.com>
Permalink:  ../Pine.BSF.4.44.0212280948590.8607-100000@themode.com/
Also on:    postgresql.org/message-id/Pine.BSF.4.44.0212280948590.8607-100000@themode.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: brew@theMode.com
  Subject: Re: pg_pconnect
  In-Reply-To: <Pine.BSF.4.44.0212280948590.8607-100000@themode.com>
  References: <20021227090902.GA2637@city.gov.te.ua> <Pine.BSF.4.44.0212280948590.8607-100000@themode.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox