Skip site navigation (1) Skip section navigation (2)

Re: taking actions on rollback (PHP)

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: taking actions on rollback (PHP)
Date: 2008-04-26 21:14:07
Message-ID: 20080426211407.GD16188@svana.org (view raw or flat)
Thread:
Lists: 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(at)svana(dot)org>   http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while 
> boarding. Thank you for flying nlogn airlines.

In response to

Responses

pgsql-general by date

Next:From: wstrzalkaDate: 2008-04-26 22:11:20
Subject: PITR problem
Previous:From: Ivan Sergio BorgonovoDate: 2008-04-26 20:52:12
Subject: taking actions on rollback (PHP)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group