commit and rollback - Mailing list pgsql-php

From WeiShang
Subject commit and rollback
Date
Msg-id dfu32l$9eb$3@news.hub.org
Whole thread Raw
Responses Re: commit and rollback  (John DeSoi <desoi@pgedit.com>)
List 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



--




pgsql-php by date:

Previous
From: "Andrei Verovski (aka MacGuru)"
Date:
Subject: Getting list of Indexes & contrains
Next
From: "JUAN ERNESTO FLORES BELTRAN"
Date:
Subject: question