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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-general by date

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