Re: taking actions on rollback (PHP) - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: taking actions on rollback (PHP)
Date
Msg-id 20080426211407.GD16188@svana.org
Whole thread Raw
In response to taking actions on rollback (PHP)  (Ivan Sergio Borgonovo <mail@webthatworks.it>)
Responses Re: taking actions on rollback (PHP)  (Ivan Sergio Borgonovo <mail@webthatworks.it>)
List pgsql-general
On Sat, Apr 26, 2008 at 10:52:12PM +0200, Ivan Sergio Borgonovo wrote:
> How am I going to see if the transaction succeeded without checking
> what happens for each statement and getting the cleanup code execute?

You basically actually check for the errors in the earlier pg_query()
calls, since they will tell you. If you can't be bothered, you could
just do at the end of the transaction:

if( !pg_query("select 1") )
  pg_query("rollback');
  // DO CLEANUP HERE
}
else
{ pg_query("commit"); }

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

Attachment

pgsql-general by date:

Previous
From: Ivan Sergio Borgonovo
Date:
Subject: taking actions on rollback (PHP)
Next
From: Ivan Sergio Borgonovo
Date:
Subject: Re: taking actions on rollback (PHP)