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

commit and rollback

From: "WeiShang" <thanks(at)verymuch(dot)com>
To: pgsql-php(at)postgresql(dot)org
Subject: commit and rollback
Date: 2005-09-10 07:48:38
Message-ID: dfu32l$9eb$3@news.hub.org (view raw or flat)
Thread:
Lists: pgsql-php
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



-- 




Responses

pgsql-php by date

Next:From: JUAN ERNESTO FLORES BELTRANDate: 2005-09-12 13:02:47
Subject: Connection Error
Previous:From: Andrei Verovski (aka MacGuru)Date: 2005-09-08 20:28:40
Subject: Getting list of Indexes & contrains

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