Re: Single database transaction across a multiple HTTP requests?
Mladen Gogala (gogala@sbcglob al.net) wrote:
: On Fri, 06 May 2005 11:12:44 -0700, noah wrote:
: > In other words, when I go to a page with a valid Cookie session I want
: > to be able to retrieve the same database connection I opened
: > previously. I don't want an automatic commit to be performed at the end
: > of the PHP script.
: Noah, HTTP is a stateless protocol. That means that no permanent
: connection is possible.
A permanent _database connection_ is certainly possible. That is exactly
how a database connection cache works. The web server opens the
connections, and then doles them out to the scripts as they need them.
When a script exits then the web server does not close the connection,
instead it keeps it open for later. The next script that "opens" a
database connection is simply given one of the open connections.
There is no theoretical reason why a script that is using one of the cache
connections could not start a database transaction, and later another
script, using the same connection, could not finish the tranaction.
Database connection caches do not normally work that way because there are
practical problems, not because it can't be done.
--
This space not for rent.
Mladen Gogala (gogala@sbcglob al.net) wrote:
: On Fri, 06 May 2005 11:12:44 -0700, noah wrote:
: > In other words, when I go to a page with a valid Cookie session I want
: > to be able to retrieve the same database connection I opened
: > previously. I don't want an automatic commit to be performed at the end
: > of the PHP script.
: Noah, HTTP is a stateless protocol. That means that no permanent
: connection is possible.
A permanent _database connection_ is certainly possible. That is exactly
how a database connection cache works. The web server opens the
connections, and then doles them out to the scripts as they need them.
When a script exits then the web server does not close the connection,
instead it keeps it open for later. The next script that "opens" a
database connection is simply given one of the open connections.
There is no theoretical reason why a script that is using one of the cache
connections could not start a database transaction, and later another
script, using the same connection, could not finish the tranaction.
Database connection caches do not normally work that way because there are
practical problems, not because it can't be done.
--
This space not for rent.
Comment