Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id DC7772E079B for ; Wed, 12 Mar 2008 05:47:41 -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 12506-07 for ; Wed, 12 Mar 2008 05:47:35 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from hs-out-0708.google.com (hs-out-0708.google.com [64.233.178.251]) by postgresql.org (Postfix) with ESMTP id D7ADF2E0366 for ; Wed, 12 Mar 2008 05:47:35 -0300 (ADT) Received: by hs-out-0708.google.com with SMTP id x43so2578683hsb.3 for ; Wed, 12 Mar 2008 01:47:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=5TUJ1vw16gRkeEUKEVcARYqMkMGji928ApD37/l7wak=; b=B4L5JxgfxJE+cHkYSQWhOUY8rg1VWDP01GtbDNbDExKDqgyUox2fNA8UAUw7H3D7NqkAFOe7UflhVK/vk6x0jK9fXbHvg1+4taSzsqRrTn2iZy5LtaFZZUFzcuKSkul4twxKk5GD5CWI5rhRYYrMOXSo+0HEgZGrJqojQHPEO3M= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=MPzXZR9FMixVL9Bc+wHsHeMrh8PNiwwb+tGjnM+5qCGUUl3Z8NbKP654ymJe7UEVbRvMdRVXUxhULZOrQFmh/HihK8JX3ZlFt/QwpYqkVKn6KPoUkEsMOnYdlBreQfy4H/h7LmRUTjGNLwb0jhspSKQfrQmPZU4dQ5GCSyCmBjA= Received: by 10.114.132.5 with SMTP id f5mr6456105wad.138.1205311653963; Wed, 12 Mar 2008 01:47:33 -0700 (PDT) Received: by 10.114.24.11 with HTTP; Wed, 12 Mar 2008 01:47:33 -0700 (PDT) Message-ID: Date: Wed, 12 Mar 2008 08:47:33 +0000 From: "A B" To: pgsql-php@postgresql.org Subject: first transactions MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=AWL=0.001 X-Spam-Level: X-Archive-Number: 200803/12 X-Sequence-Number: 3837 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. :-)