Re: pg_pconnect

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



On Fri, 27 Dec 2002 sector119@xxxxxxx 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>";
> ?>
>
>




[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux