Opinions on how to Integrate Transactions

From: APseudoUtopia <apseudoutopia(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Opinions on how to Integrate Transactions
Date: 2009-06-14 15:14:04
Message-ID: 27ade5280906140814o4b9d89b6p7e53c55b3a5bd2e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hey,

I'm new to using transactions. I'd like to integrate them into my PHP
application to prevent a few issues we've been having. Such as, some
queries in the beginning of the php script running, then an error
occurring, preventing queries toward the bottom of the script from
running. It's leaving me with things such as a forum topic without any
associated forum posts. From what I've read on transactions, they
would be the solution to my problems.

So I have a couple questions about them.

1. Is there a way to list active transactions on all databases? I'd
like a way to see if there are any "idle" transactions that are just
hanging there. Is there a way to "kill" them from the console?

2. I have a PHP class which communicates with the DB, which is
included into every other page on the site. Should I just add BEGIN
and COMMIT at the beginning and end of the class? This way, I wont
need to edit every single page on my site to include BEGIN and COMMIT?
Or will that type of "blind" transactions cause problems?

3. What happens when there IS an error? Do I need to run ROLLBACK
every time? Or will it automatically reset when the connection is
closed when the PHP script dies?

Thanks for the advice.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Petr Jelinek 2009-06-14 15:59:58 Re: [GENERAL] Using results from DELETE ... RETURNING
Previous Message Tom Lane 2009-06-14 15:03:35 Re: terminating connection because of crash of another server process