From: ljb <ljb220@mindspring.com>
To: pgsql-php@postgresql.org
Subject: Re: problem--pg_connect() and odbc_connect() return the same connection
Date: Wed, 26 Nov 2003 02:10:00 +0000 (UTC)
Message-ID: <bq121o$r2h$1@news.hub.org> (raw)
References: <3FBD6468.5010107@shentel.net>
pntil@shentel.net wrote:
> I was having problems because pg_connect() (and odbc_connect()), when
> given the same connection credentials, return the SAME IDENTICAL
> connection.
>
> Given this, it is difficult to write functions that use a database
> connection but do not have unwanted side effects.
> ...
> It seems to me that much of the transaction handling, and the (ACIDity
> therein) of postgresql is lost because of this "feature" that multiple
> connection requests with the same parameters return the same exact
> connection.
>
> How do you web developers out there deal with this? Do you have some
> elegant workaround for this?
>
> Also, is there anyone on this list who works on the PHP pg_xxxxx
> extension? Has this issue ever been brought up before?
I think in many cases we wouldn't want a single script to open multiple
connections to PostgreSQL due to the per-connection overhead and limited
number of backends available. But if you really want to, there is a way
with the PostgreSQL extension:
$conn_handle = pg_connect($connstring, PGSQL_CONNECT_FORCE_NEW);
This gives you a fresh new connection regardless of any existing connection
which used the same connection info string $connstring. This feature was
added in PHP-4.3.0, so make sure you are running at least that version. It
hasn't really made the documentation, so it might be considered experimental.
But it works.
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: ljb220@mindspring.com
Subject: Re: problem--pg_connect() and odbc_connect() return the same connection
In-Reply-To: <bq121o$r2h$1@news.hub.org>
References: <3FBD6468.5010107@shentel.net> <bq121o$r2h$1@news.hub.org>
* 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