X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0B326D899C for ; Tue, 13 Sep 2005 08:54:23 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 43352-02 for ; Tue, 13 Sep 2005 11:54:17 +0000 (GMT) Received: from a2s4.a2hosting.com (a2s4.a2hosting.com [64.9.205.220]) by svr1.postgresql.org (Postfix) with ESMTP id 6AC00D7F2B for ; Tue, 13 Sep 2005 08:54:18 -0300 (ADT) Received: from user-1120cav.dsl.mindspring.com ([66.32.49.95] helo=[192.168.1.10]) by a2s4.a2hosting.com with esmtpsa (TLSv1:RC4-SHA:128) (Exim 4.52) id 1EF9Mg-0005RB-Lc; Tue, 13 Sep 2005 07:54:18 -0400 In-Reply-To: References: Mime-Version: 1.0 (Apple Message framework v733) X-Priority: 3 Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <8FA61462-4BE2-44F7-9F6D-1B75C5F452B9@pgedit.com> Cc: pgsql-php@postgresql.org Content-Transfer-Encoding: 7bit From: John DeSoi Subject: Re: commit and rollback Date: Tue, 13 Sep 2005 07:53:55 -0400 To: WeiShang X-Mailer: Apple Mail (2.733) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - a2s4.a2hosting.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - pgedit.com X-Source: X-Source-Args: X-Source-Dir: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 required=5 tests=[AWL=0.007] X-Spam-Level: X-Archive-Number: 200509/11 X-Sequence-Number: 3251 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