commit and rollback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



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



-- 





[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux