pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: mikie <mikie.pl@gmail.com>
To: pgsql-php@postgresql.org
Subject: Re: transactions from PHP - double COMMIT required?
Date: Thu, 1 Mar 2007 13:45:08 +0100
Message-ID: <ca35ce500703010445n67ca6714id0b10b393859f8e0@mail.gmail.com> (raw)
In-Reply-To: <e0b20d410703010418m3f931527wb2e81e3f3ab0c9f4@mail.gmail.com>
References: <ca35ce500703010306nd06dcfcy1247fb2b4297b0c2@mail.gmail.com>
	<20070301131523.fgfm83nb9y2kgo4c@imp3.uta.fi>
	<ca35ce500703010329j329b8a5h6ee8958ddb6711e0@mail.gmail.com>
	<e0b20d410703010418m3f931527wb2e81e3f3ab0c9f4@mail.gmail.com>

2007/3/1, David Legault <legault.david@gmail.com>:
> If you are using PHP5 (and the PDO PGSQL) I would suggest you use exceptions to trap the error
>
> try {
>
>  $db->beginTransaction();
>
>  // other queries here, if one fails, an exception is thrown
>
>  $db->commit();
> }
> catch (Exception $e) {
>
>  // do whatever with error
>  $db->rollback();
>
> }

Yes, that is nice way to work with databases, but I am on PHP4 and I
am not using the PDO.
But getting back to my problem - perhaps there is something I
misunderstood: is it the client application responsibility to check if
the transaction failed or succeeded and issue COMMIT or ROLLBACK
accordingly (how do I close the transaction block in that case)?
Or is it the database server that is suppose to check if transaction
succeded and perform the query, or ROLLBACK if anything went wrong?

-- 
Mike



view thread (23+ messages)  latest in thread

Message-ID: <ca35ce500703010445n67ca6714id0b10b393859f8e0@mail.gmail.com>
Permalink:  ../ca35ce500703010445n67ca6714id0b10b393859f8e0@mail.gmail.com/
Also on:    postgresql.org/message-id/ca35ce500703010445n67ca6714id0b10b393859f8e0@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: mikie.pl@gmail.com
  Subject: Re: transactions from PHP - double COMMIT required?
  In-Reply-To: <ca35ce500703010445n67ca6714id0b10b393859f8e0@mail.gmail.com>
  References: <ca35ce500703010306nd06dcfcy1247fb2b4297b0c2@mail.gmail.com> <20070301131523.fgfm83nb9y2kgo4c@imp3.uta.fi> <ca35ce500703010329j329b8a5h6ee8958ddb6711e0@mail.gmail.com> <e0b20d410703010418m3f931527wb2e81e3f3ab0c9f4@mail.gmail.com> <ca35ce500703010445n67ca6714id0b10b393859f8e0@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox