From: Volkan YAZICI <yazicivo@ttnet.net.tr>
To: Martin Marques <martin@bugs.unl.edu.ar>
Cc: pgsql-php@postgresql.org
Subject: Re: 2 distinct connections
Date: Sat, 27 May 2006 17:40:30 +0300
Message-ID: <20060527144030.GC25675@alamut> (raw)
In-Reply-To: <Pine.LNX.4.61.0605270916100.21989@bugs.unl.edu.ar>
References: <Pine.LNX.4.61.0605270916100.21989@bugs.unl.edu.ar>
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.
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: yazicivo@ttnet.net.tr, martin@bugs.unl.edu.ar
Subject: Re: 2 distinct connections
In-Reply-To: <20060527144030.GC25675@alamut>
References: <Pine.LNX.4.61.0605270916100.21989@bugs.unl.edu.ar> <20060527144030.GC25675@alamut>
* 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