From: | Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp> |
---|---|
To: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Transactions and PHP and persitent connections |
Date: | 2002-08-31 08:54:31 |
Message-ID: | 3D708447.9050503@mega-bucks.co.jp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I've posted this to the PHP-db list also, but I find the people on this
list usually more precise in their answers so I was hoping someone here
might be able to help me.
I'm a little confused/worried about database transactions, persistent
connections and PHP. (Of course I am using postgresQL :)
I am worried that if I use persistent connections it might be possible
for more than one PHP script to be inside the same transaction at the
same time.
For example:
1- page1.php is a script that opens a persistent connection to a DB and
starts a transaction.
2- User 1 goes to page1.php
3- User 2 goes to page1.php
My questions:
1- is it possible that user 2 will be using the same connection as user
1? So if user 1's transaction fails so will user 2's?
2- If user 1's hits the stop button on his browser, what happens to his
transaction? I assume it is stopped. But what about the connection? If
user 2 gets the same connection, will his transaction fail?
3- If I don't use persistent connections, do all my worries go away?
I've abstracted the DB layer out of my code, but one side-effect is that
each SQL statement causes a new connection to be made. If a script
wanted to do the following:
BEGIN;
INSERT into t values('1');
COMMIT;
my code would actually create one connection per SQL statement. PHP is
supposed to re-use the same backend if a running script open a new
connection with the same parameters but I am worried that it doesn't,
and so transactions may fail.
I've never used transactions before, and even though they are a simple
concept, I'm worried that going through PHP might result in unexpected
behaviour.
Thanks,
Jc
From | Date | Subject | |
---|---|---|---|
Next Message | Gurkan Sengun | 2002-08-31 10:17:22 | postgresql banner |
Previous Message | Garo Hussenjian | 2002-08-31 06:00:18 | Bigint in sequences |