Re: persistent db connections in PHP - Mailing list pgsql-general

From Martin Gainty
Subject Re: persistent db connections in PHP
Date
Msg-id BAY108-DAV140F92CB1AD5BEA670AF8EAE1D0@phx.gbl
Whole thread Raw
In response to persistent db connections in PHP  (lawpoop@gmail.com)
Responses Re: persistent db connections in PHP  (lawpoop@gmail.com)
List pgsql-general
At least in mySQL Any temporary tables are known only t the connection that
you have created e.g.

/*****connected as root to localhost *********/
mysql> CREATE TEMPORARY TABLE test.TEMP_TABLE (COL VARCHAR(20));
ERROR 1050 (42S01): Table 'temp_table' already exists
mysql> SELECT * from test.TEMP_TABLE;
Empty set (0.00 sec)

mysql> INSERT INTO test.TEMP_TABLE VALUES ('FooBar');
Query OK, 1 row affected (0.02 sec)
mysql> commit;
Query OK, 0 rows affected (0.00 sec)

mysql> select * from test.TEMP_TABLE;
+--------+
| COL    |
+--------+
| FooBar |
+--------+
1 row in set (0.00 sec)
/**********we see that the TEMP_TABLE exists and has 1 row of Data Inserted
*******/

/************Second connection ****************/
C:\MySQL>.\bin\mysql -u test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 26
Server version: 5.0.37-community-nt MySQL Community Edition (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> status;
--------------
\bin\mysql  Ver 14.12 Distrib 5.0.37, for Win32 (ia32)

Connection id:          26
Current database:
Current user:           test@localhost
SSL:                    Not in use
Using delimiter:        ;
Server version:         5.0.37-community-nt MySQL Community Edition (GPL)
Protocol version:       10
Connection:             localhost via TCP/IP
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    latin1
Conn.  characterset:    latin1
TCP port:               3306
Uptime:                 2 hours 29 min 21 sec

Threads: 2  Questions: 64  Slow queries: 0  Opens: 25  Flush tables: 1  Open
tab
les: 6  Queries per second avg: 0.007
--------------

mysql> select * from test.TEMP_TABLE;
ERROR 1146 (42S02): Table 'test.temp_table' doesn't exist

/*********this proves that a second connection cannot see temp tables
created by the first connection*****/
I *****assume***** the same is true for Postgres!

HTH
Martin--
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.

----- Original Message -----
From: <lawpoop@gmail.com>
To: <pgsql-general@postgresql.org>
Sent: Friday, June 15, 2007 10:52 AM
Subject: [GENERAL] persistent db connections in PHP


> Hello all!
>
> I'm working on a PHP site using Postgres as a back-end. I have an
> include at the top of each page that runs the pg_connect function.
>
> I'm implementing some temporary tables, which I understand are
> destroyed automatically at the end of the session. It seems to me that
> when I navigate to a new page, or re-load my existing page, I lose my
> temporary tables. Is this because I am creating a new session at the
> beginning of each page with my pg_connect include?
>
> Also, are temporary tables globally visible, or only within that
> session? I mean, can one user see another user's temporary tables?
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Dynamically generating DDL for postgresql object
Next
From: PFC
Date:
Subject: Re: persistent db connections in PHP