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

first transactions

From: "A B" <gentosaker(at)gmail(dot)com>
To: pgsql-php(at)postgresql(dot)org
Subject: first transactions
Date: 2008-03-12 08:47:33
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-php

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
  $result = pg_query("update ***",$db);
  $result = pg_query("select ***",$db);
  $result = pg_query("insert ***",$db);
  $result = pg_query("update ***",$db);
  if everything was successfully committed
       return true;
      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. :-)


pgsql-php by date

Next:From: Jeff MacDonaldDate: 2008-03-12 16:29:03
Subject: Re: first transactions
Previous:From: John CartwrightDate: 2008-03-11 13:59:44
Subject: Re: pg_connect fails, pgsql works

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