X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 61A139FA315 for ; Sat, 27 May 2006 11:43:04 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 67241-08 for ; Sat, 27 May 2006 11:42:53 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from fep02.ttnet.net.tr (mail.ttnet.net.tr [212.175.13.129]) by postgresql.org (Postfix) with ESMTP id 9AE109FA0EC for ; Sat, 27 May 2006 11:42:51 -0300 (ADT) Received: from (192.168.8.102) by AVGW-I-2.ttnet.net.tr via smtp id 5d3f_e380f71e_ed8e_11da_8330_001422175af5; Sat, 27 May 2006 17:41:33 +0300 Received: from alamut ([85.101.243.96]) by fep02.ttnet.net.tr with ESMTP id <20060527144247.OOBZ1367.fep02.ttnet.net.tr@alamut>; Sat, 27 May 2006 17:42:47 +0300 Received: from (85.101.243.96) by AVGW-I-1.ttnet.net.tr via smtp id 736d_f2368f58_ed8e_11da_9201_001422175f0e; Sat, 27 May 2006 17:41:57 +0300 Date: Sat, 27 May 2006 17:40:30 +0300 From: Volkan YAZICI To: Martin Marques Cc: pgsql-php@postgresql.org Subject: Re: 2 distinct connections Message-ID: <20060527144030.GC25675@alamut> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.1i X-NAI-Spam-Rules: 1 Rules triggered BAYES_00=-2.5 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/25 X-Sequence-Number: 3525 On May 27 09:37, Martin Marques wrote: > We're working on a project using PHP and PostgreSQL, mainly trying to work > in an OOP fashion. The project has quite a good amount of code, and a DB > Object called DB_Bib that has all the query methods. I also have a generic > DB object (DB_Main) which has code to establesh the connection, and from > which my DB_bib Inerits the DB connection. > > The thing is that I made a new class called DB_Debug which also inherits > from DB_Main, and is there to have debugging data inserted into a table in > the database. > > I noticed that when the two objects are started (they both call the > connection method using the same connection string) php doesn't > initiate to distinct connections, but 1 connection within commands from > both objects get passed to the DB server. > > The problem is that query commands from the DB_Debug object and from the > DB_Bib object get mixed up in the same connection, making it deficult to > know when to make a commit. As Cornelia Boenig suggested, you can force pg_connect() to establish a new connection on every call. Also if you don't want to exhaust max_connections limit, you can serialize queries using semaphores (or mutex). Regards.