Re: Checking data inserted during a transaction

From: Keary Suska <hierophant(at)pcisys(dot)net>
To: Postgres-PHP <pgsql-php(at)postgresql(dot)org>
Subject: Re: Checking data inserted during a transaction
Date: 2004-05-13 20:31:20
Message-ID: BCC93738.10CF3%hierophant@pcisys.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

on 5/12/04 4:45 PM, lynna(at)gallery44(dot)org purportedly said:

> Because information has to be entered into several different tables for each
> exhibition, I've broken down the process of adding new exhibitions to the
> databases into several pages, each of which processes the form data sent
> from the previous page and then guides users through the next step (artists
> featured in the exhibition, etc.).
>
> I'm using transactions to handle this, so that at the end of the process the
> user can (hopefully) review the data they've entered and either commit or
> rollback the changes. But I'm having a bit of trouble figuring out whether
> the data I'm trying to insert during the transaction is actually being
> inserted.
>
> From what I've read about transactions thus far, it looks to me as though
> the data inserted should be visible in the database after the insert is done
> but before the commit or rollback happens, and then disappear if rollback is
> chosen. But that doesn't seem to be working.

As was mentioned, only the connection/process that "owns" the transaction
can see information altered within the transaction. In short, the answer to
your question is, "you can't."

You have a bigger issue, however. Because of the stateless nature of HTTP
and how PHP/Apache implements database connections, your multi-page process
will likely fail, as there is no guarantee that on any subsequent HTTP
requests that you will be using an existing connection/process (see also
first paragraph).

To use a multi-stage process, you will need to preserve the data yourself
(i.e. not insert into DB) at each step until the process is confirmed by the
end user. If the data is not too large you can preserve it within session
variables. Otherwise you may want to create a "safe" temp file, a reference
to which is maintained by the session.

Best regards,

Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"

In response to

Browse pgsql-php by date

  From Date Subject
Next Message Paul Lynch 2004-05-16 12:14:15 Re: Parsing Data, Table to Form
Previous Message Raul Secan 2004-05-13 07:01:20 Installing PostgreSQL on Fedora from RPM