Re: possible bug in DB/pgsql.php

From: Date: Mon, 12 Feb 2001 17:20:52 +0000
Subject: Re: possible bug in DB/pgsql.php
References: 1  Groups: php.pear 
Request: Send a blank email to php-pear+get-1327@lists.php.net to get a copy of this message
On 12 Feb 2001, at 18:43, Burak DAYIOGLU wrote: > The below code is assumed to make two inserts and rollback afterwards. > I was expecting to see no records inserted however both inserts ended > with success. > In reality, $database->autocommit(FALSE) should have raised an error, since it's not supported in the PGSQL port (at least in my version)... > Any ideas on how to implement transactions with postgresql? Am I doing > anything wrong? (BTW, running on RH6.2 Linux w/ Php4.0.4pl1, cvs > synched fresh PEAR and pgsql 7.0.3...) > Considering PG API, I think the most straightforward way is to add a "start transaction" method, simmetric to $db->commit() and $db->rollback - say, something like $db->begin(). It could be done by hacking DB/pgsql or by subclassing it. Being from PHPlib background, I'd suggest the latter :-) The code for that method should be quite simple: function begin() { $result = pg_exec($this->connection, "begin;"); if (!$result) { return pg_errormessage($this->connection); } return DB_OK; } Implementing this using the $db->autocommit() flag would be a lot more painful, IMVHO. /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ Fabrizio Ermini Alternate E-mail: C.so Umberto, 7 faermini@tin.it loc. Meleto Valdarno Mail on GSM: (keep it short!) 52020 Cavriglia (AR) faermini@sms.tin.it

« previous php.pear (#1327) next »