Transactions in Postgres - Mailing list pgsql-novice

From root
Subject Transactions in Postgres
Date
Msg-id 3CAB0046.71962952@hailix.com
Whole thread Raw
Responses Re: Transactions in Postgres  (Ivan Horvath <pillesoft@yahoo.co.uk>)
Re: Transactions in Postgres  ("Josh Berkus" <josh@agliodbs.com>)
Re: Transactions in Postgres  (Ugly Hippo <ugly_hippo@yahoo.ca>)
List pgsql-novice
HI,

I am running Postgresql-7.2 with PHP 4.1.1 and I am beginning to use
transactions inside of a php script:

$Link = pg_connect("host=$Host dbname=$DBName user=$User") or die
("Couldn't connect to the database $DBName");

 $Query = "BEGIN WORK; INSERT into $TableName
(firstname,lastname,emailaddress,comments,created)
values('$Array[FirstName]',
'$Array[LastName]','$Array[email]','$Array[Comments]', 'now()');
COMMIT;";

 // Test to see if the query was succeful or not

 pg_exec($Link, $Query) or die ("Couldn't insert name $firstname");

 if (pg_exec($Link,$Query)) {
 echo "<h1>Insert was successful</h1>";
 } else {
 echo "<H1>Insert was not successful</H1>";

What I am finding is that this query will insert a new name twice in the
database within milliseconds of each other.  What am I missing in doing
this?  Any help is appreciated.

Trevor


pgsql-novice by date:

Previous
From: cristi voinicaru
Date:
Subject: Date
Next
From: Harald Lux
Date:
Subject: Re: Formatted printing output