Single database transaction across a multiple HTTP requests?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Malcolm Dew-Jones

    #16
    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.

    Comment

    • Tony Marston

      #17
      Re: Single database transaction across a multiple HTTP requests?


      "Malcolm Dew-Jones" <yf110@vtn1.vic toria.tc.ca> wrote in message
      news:427edda0@n ews.victoria.tc .ca...[color=blue]
      > 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.[/color]

      The problem with this is that you cannot guarantee that a subsequent request
      belonging to a session will be given the same connection as was used
      previously by thesame session. Each of those pooled connections could be
      given to anybody as they are not tied to a single session.

      --
      Tony Marston

      This is Tony Marston's web site, containing personal information plus pages devoted to the Uniface 4GL development language, XML and XSL, PHP and MySQL, and a bit of COBOL


      [color=blue]
      > 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.[/color]


      Comment

      Working...