Re: Re: DB_DataObject and Transactions

From: Date: Sun, 04 Apr 2004 19:04:49 +0000
Subject: Re: Re: DB_DataObject and Transactions
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-11614@lists.php.net to get a copy of this message
On Sun, 04 Apr 2004 20:49:24 +0200, stefan@neufeind.net (Stefan Neufeind) wrote: >Maybe consider posting it here, so it can be helpful for others as >well. Think about the mailinglist-archives ... Yes of course (I'm haven't thought about the archive, cause using a newsreader ;) ) Getting the Transactions running with DataObjects is fairly simple. $dbo = new DO_Tablea(); $conn = $dbo->getDatabaseConnection(); $res = $conn->query("BEGIN TRANSACTION"); $dbo->datax = "abcd"; $dbo->insert(); $dbo2 = new DO_Tableb(); $dbo2->datay = "fdsa"; $dbo2->insert(); [... do what ever you want with a dataobject of your choice with the SAME databaseconnection...] $res = $conn->query("ROLLBACK"); // Cancel changes/inserts/deletes or $res = $conn->query("COMMIT"); // Commit (Used on a postgres working find BUT: There is only one pitfall I've seen: It's the sequence. It's not cancelled. I think this may be a problem with the DataObjects (Maybe they'll use a diffrent connection to search for the next id)).

« previous php.pear.general (#11614) next »