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

Re: commit and rollback

From: John DeSoi <desoi(at)pgedit(dot)com>
To: WeiShang <thanks(at)verymuch(dot)com>
Cc: pgsql-php(at)postgresql(dot)org
Subject: Re: commit and rollback
Date: 2005-09-13 11:53:55
Message-ID: 8FA61462-4BE2-44F7-9F6D-1B75C5F452B9@pgedit.com (view raw or flat)
Thread:
Lists: pgsql-php
On Sep 10, 2005, at 3:48 AM, WeiShang wrote:

> I have a problem about commit and rollback using php. For the  
> script below,
> if "foo" is called and commit and if rollback statment also run.  
> Will the
> update statement under foo also rollback? or commit?


It will commit, but it will also complete the transaction causing  
everything after it to run outside the transaction. Probably not what  
you would want to do.

If foo can be called both inside and outside of a transaction, you  
should call pg_transaction_status (assuming PHP 5) and only begin/ 
commit in foo if there is no existing transaction. If you are not  
using PHP 5, then setup some flag to know if you are in a transaction.


John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL


In response to

pgsql-php by date

Next:From: Marc McIntyreDate: 2005-09-19 23:09:03
Subject: Re: Getting list of Indexes & contrains
Previous:From: Alban Medici (NetCentrex)Date: 2005-09-13 07:58:41
Subject: Re: Getting list of Indexes & contrains

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