pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: WeiShang <thanks@verymuch.com>
To: pgsql-php@postgresql.org
Subject: commit and rollback
Date: Sat, 10 Sep 2005 15:48:38 +0800
Message-ID: <dfu32l$9eb$3@news.hub.org> (raw)

Hi,

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?

Thanks in advance!

----------------------------------------------------------------------------
-----------Script starts
function foo(var1,var2)
{
   pg_query($db,"begin");
   pg_query($db,"<update statement here>");
   pg_query($db,"commit");
}


pg_query($db,"begin");

.....
foo(v1,v2);

$result1=pg_query($db,"<update statment here>");
if (pg_affected_rows($result)==0)
    pg_query($db,"rollback");
else
    pg_query($db,"commit");

----------------------------------------------------------------------------
-----------Script end



-- 






view thread (2+ messages)  latest in thread

Message-ID: <dfu32l$9eb$3@news.hub.org>
Permalink:  ../dfu32l$9eb$3@news.hub.org/
Also on:    postgresql.org/message-id/dfu32l$9eb$3@news.hub.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: thanks@verymuch.com
  Subject: Re: commit and rollback
  In-Reply-To: <dfu32l$9eb$3@news.hub.org>
  References: <dfu32l$9eb$3@news.hub.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox