X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2A1F4D1B488 for ; Wed, 26 Nov 2003 02:21:55 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 69298-06 for ; Tue, 25 Nov 2003 22:21:26 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 894FBD1B49F for ; Tue, 25 Nov 2003 22:21:24 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id hAQ2LNNw029454 for ; Wed, 26 Nov 2003 02:21:24 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id hAQ2A14Q028106 for pgsql-php@postgresql.org; Wed, 26 Nov 2003 02:10:01 GMT From: ljb X-Newsgroups: comp.databases.postgresql.interfaces.php Subject: Re: problem--pg_connect() and odbc_connect() return the same connection Date: Wed, 26 Nov 2003 02:10:00 +0000 (UTC) Organization: Hub.Org Networking Services Lines: 31 Message-ID: References: <3FBD6468.5010107@shentel.net> X-Complaints-To: usenet@news.hub.org User-Agent: slrn/0.9.8.0 (Linux) To: pgsql-php@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/48 X-Sequence-Number: 2441 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.