From: reiner peterke <zedaardv@drizzle.com>
To: pgsql-php@postgresql.org
Subject: getting transactions to work
Date: Fri, 30 Jul 2004 16:53:01 +0200
Message-ID: <27ABA345-E238-11D8-8EE0-000A95984CA6@drizzle.com> (raw)
there seems to be very little info around on actually using
transactions with postgres. i've tried to create a page that will take
input from a form and insert it into my database. it works if i just
do it without transactions but when i try to use with the begin and
commit sections of code, it doesn't update the data base. i'm guessing
it is doing a rollback when my page loads itself again. can anyone
help me out here ?
thanks
r
code below
<html>
<head>
<submitle>those eyes</submitle>
</head>
<body>
<?
$conn = pg_connect("dbname=entish user=postgres");
if(!$conn)
{
print "not for the chocolate";
exit;
}
if ($_POST[submit]) {
$begin = pg_query("begin");
$isql = "insert into diety(diety,culture,gender)
values
('$_POST[diety]','$_POST[culture]','$_POST[gender]')";
printf("-- %s --\n",$isql);
$results = pg_query($isql);
?>
<form method="post" action="<? echo $PHP_SELF?>">
<input type="Submit" name="action" value="commit">
<input type="Submit" name="action" value="rollback">
</form>
<?
}
else if(!$_POST[action]) {
?>
<form method="post" action="<? echo $PHP_SELF?>">
Diety:<input type="text" name="diety"><br>
Culture:<input type="text" name="culture"><br>
Gender:<input type="text" name="gender"><br>
<input type="Submit" name="submit" value="enter">
</form>
<?
}
else {
if($_POST[action] == 'commit') {
echo "let me see";
$act = pg_query("commit");
}
else {
$act = pg_query("rollback");
}
} //end if $_POST[submit]
?>
</body>
</html>
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: zedaardv@drizzle.com
Subject: Re: getting transactions to work
In-Reply-To: <27ABA345-E238-11D8-8EE0-000A95984CA6@drizzle.com>
References: <27ABA345-E238-11D8-8EE0-000A95984CA6@drizzle.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