From: A B <gentosaker@gmail.com>
To: pgsql-php@postgresql.org
Subject: first transactions
Date: Wed, 12 Mar 2008 08:47:33 +0000
Message-ID: <dbbf25900803120147l6900fc28rac8b5789f95b4a27@mail.gmail.com> (raw)
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. :-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-php@postgresql.org
Cc: gentosaker@gmail.com
Subject: Re: first transactions
In-Reply-To: <dbbf25900803120147l6900fc28rac8b5789f95b4a27@mail.gmail.com>
References: <dbbf25900803120147l6900fc28rac8b5789f95b4a27@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox