first transactions

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



Hello.

I think I need some help on making it clear on how to use transactions
in php in a "correct" way.

Lets consider this code/pseudocode

function dostuff()
{
$db = pg_pconnect...;
pg_query("begin work",$db);
$result = pg_query("select ***",$db);
$result = pg_query("insert ***",$db);

if previous query failed, then rollback and return false
else
{
  $result = pg_query("update ***",$db);
  $result = pg_query("select ***",$db);
  $result = pg_query("insert ***",$db);
  $result = pg_query("update ***",$db);
  pg_query("commit,$db);
  if everything was successfully committed
       return true;
  else
      return false or some other kind of error status to tell what went wrong.
}

} //end function

So the question is: how do I write the pseudocode parts in php?
Any other general suggestions on how to make the function more "fool
proof" is appreciated. :-)

-- 
Sent via pgsql-php mailing list (pgsql-php@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-php

[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