Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 4641F2E02F0 for ; Wed, 12 Mar 2008 13:50:05 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 68228-02 for ; Wed, 12 Mar 2008 13:49:47 -0300 (ADT) X-Greylist: delayed 00:20:36.318634 by SQLgrey-1.7.5 Received: from hermes.zoidtechnologies.com (hermes.zoidtechnologies.com [204.11.32.103]) by postgresql.org (Postfix) with ESMTP id 6BF922E334F for ; Wed, 12 Mar 2008 13:49:43 -0300 (ADT) Received: from toast.zoidtechnologies.com (75-138-55-184.dhcp.gnvl.sc.charter.com [75.138.55.184]) by hermes.zoidtechnologies.com (Postfix) with ESMTP id 61A9113C225; Wed, 12 Mar 2008 12:32:09 -0400 (EDT) Received: from dionysus.zoidtechnologies.com (dionysus.zoidtechnologies.com [192.168.2.9]) by toast.zoidtechnologies.com (Postfix) with ESMTP id D3449206D78; Wed, 12 Mar 2008 12:29:04 -0400 (EDT) From: Jeff MacDonald Organization: Zoid Technologies To: pgsql-php@postgresql.org Subject: Re: first transactions Date: Wed, 12 Mar 2008 11:29:03 -0500 User-Agent: KMail/1.9.6 (enterprise 20070904.708012) Cc: "A B" References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200803121229.04237.jam@zoidtechnologies.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200803/13 X-Sequence-Number: 3838 On Wednesday 12 March 2008 4:47:33 am A B wrote: > 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 > [...snipped...] > 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. :-) I recommend use of PEAR::MDB2[1] or "PDO"[2].. typically what I do is run the query, rollback if error, continue if not. if you want to be extra thorough using MDB2, you can check to make sure the database supports transactions, and after a "begin" you can make sure that the transaction has been started. my understanding is that PDO has a *very* similar interface to MDB2, except that PDO is written in C. hope that helps some.. if you have more questions post again or email me directly. regards, jeff [1] http://pear.php.net/mdb2 [2] http://php.net/pdo -- http://zoidtechnologies.com/ "websites that suck less"