Re: Re: DB_DataObject and transactions

From: Date: Tue, 21 Sep 2004 14:16:29 +0000
Subject: Re: Re: DB_DataObject and transactions
References: 1 2 3 4 5  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-14577@lists.php.net to get a copy of this message
Markus Wolff wrote:
Alan Knowles wrote:
Laszlo Hermann wrote:
$person = DB_DataObject::factory('person');
$conn = & $person->getDatabaseConnection(); $conn->autocommit();
AFAIR - this may fail if you have not disabled overload on PHP4, (due to bugs in the overload extension) which is why the $do->query('BEGIN') is the recommended way to do it.
Will 'BEGIN' work on all databases?
Yes - the code in dataobjects does something like this function query($str) { if ($str == 'BEGIN') {
      $con = $_DATAOBJECT['connections'][$this->connectionmd5] ->autocommit(false);
      return;
} } It was done that way originally to reduce bloat on the API, but had a nice side effect of getting around the overload bug.. Regards Alan
So far, I've seen at least five flavours of begin transaction syntax: BEGIN, BEGIN TRANSACTION, SET TRANSACTION, START TRANSACTION and BEGIN WORK, depending on the DBMS. Seems PostgreSQL can cope with all of these except the SET and START syntax, MySQL seems to be able to use BEGIN, BEGIN WORK and START TRANSACTION, Microsoft SQL Server seems to only be able to cope with BEGIN TRANSACTION, but adds the abbreviation BEGIN TRAN to the mix. A pure "BEGIN" would break on this one. Oracle, at least version 7, seems to only understand SET TRANSACTION. Dunno about others. CU Markus


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