Re: persistent db connections in PHP

From: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
To: lawpoop(at)gmail(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: persistent db connections in PHP
Date: 2007-06-20 19:32:43
Message-ID: 467980DB.2020805@g2switchworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

lawpoop(at)gmail(dot)com wrote:
> This seems to be a problem with PHP, or at least my set up.
>
> I'm writing pages in basically the same way. Each page has an include
> at the top that gets you a database session. The function, either
> pg_connect() or mysql_connect(), is supposed to either create a new
> connection, or return your existing one.
>
> So after I have a connection, I can navigate to other pages, reload or
> post to the current one, trigger the x_connect(), and get the session
> I created earlier.
>
> In my Mysql site, if I create temporary tables, I still have access to
> them after I have traversed a mysql_connect. So it looks like PHP is
> giving me the connection I had when I created the temp tables.
>
> However, with this new Postgres site, I don't have access to my temp
> tables after I've traversed another pg_connect. So PHP is either
> creating a new connection, or giving me another session, not the one
> which I created my tables in.

MySQL reuses old connections within the same script. PostgreSQL's php
extension does not, it starts a new connection each time.

MySQL's behaviour is surprising, PostgreSQL's behaviour is what you'd
expect. Which is typical of both dbs.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2007-06-20 19:32:55 Re: Running OS-level programs from Postgres?
Previous Message Scott Marlowe 2007-06-20 19:27:22 Re: allocate chunk of sequence