pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Martín Marqués <martin@bugs.unl.edu.ar>
To: pgsql-php@postgresql.org
Subject: Re: db connections in session variables
Date: Tue, 13 Nov 2001 18:49:41 -0300
Message-ID: <20011113214943.350272AB48@bugs.unl.edu.ar> (raw)
In-Reply-To: <OFD16A9778.5F12758D-ON85256B03.0066298C@hartehanks.com>
References: <OFD16A9778.5F12758D-ON85256B03.0066298C@hartehanks.com>

On Mar 13 Nov 2001 17:36, you wrote:
> I was wondering if it were possible to store a database connection in a
> session variable.

No! Because the persistent connection gets opened with one child, and when 
you go for the next page you have very high probabilities (unless you have a 
very poor http configuration) of caching a new child, and not the old one.

The problem comes here, just because the pconnect was done against the old 
child, and the new one doesn't know a thing about the pconnect you did 
before, so you'll allways (or almost always) an error of "wrong connection 
id".

Hope I was clear.

> I have tried these 2 methods:
>
> $conn = pg_pconnect("server", "5432", "db");
> session_start();
> session_register('conn');
>
> $conn = pg_pconnect("server", "5432", "db");
> session_id($conn);
> session_start();
>
> both of them register a session with the value of "Resource id #1" but
> don't act as a db connection.  I am just trying to clean up some code so I
> don't have to do a new database connection on every page that I create.
>
> Then if you are able to do this, where would you close the connection?
>
> I guess in ASP, it is possible to store db connections in a session
> variable.  I have never done it there either but someone told me that you
> can.
>
> Tim.
>
> Timothy P. Maguire
> Web Developer II
> Harte-Hanks
> 978 436 3325
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org

-- 
Porqué usar una base de datos relacional cualquiera,
si podés usar PostgreSQL?
-----------------------------------------------------------------
Martín Marqués                  |        mmarques@unl.edu.ar
Programador, Administrador, DBA |       Centro de Telematica
                       Universidad Nacional
                            del Litoral
-----------------------------------------------------------------



view thread (3+ messages)  latest in thread

Message-ID: <20011113214943.350272AB48@bugs.unl.edu.ar>
Permalink:  ../20011113214943.350272AB48@bugs.unl.edu.ar/
Also on:    postgresql.org/message-id/20011113214943.350272AB48@bugs.unl.edu.ar

 · 

reply

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: martin@bugs.unl.edu.ar
  Subject: Re: db connections in session variables
  In-Reply-To: <20011113214943.350272AB48@bugs.unl.edu.ar>
  References: <OFD16A9778.5F12758D-ON85256B03.0066298C@hartehanks.com> <20011113214943.350272AB48@bugs.unl.edu.ar>

* 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