Class TDbTransaction

Description

TDbTransaction class.

TDbTransaction represents a DB transaction. It is usually created by calling TDbConnection::beginTransaction.

The following code is a common scenario of using transactions:

  1.  try
  2.  {
  3.     $transaction=$connection->beginTransaction();
  4.     $connection->createCommand($sql1)->execute();
  5.     $connection->createCommand($sql2)->execute();
  6.     //.... other SQL executions
  7.     $transaction->commit();
  8.  }
  9.  catch(Exception $e)
  10.  {
  11.     $transaction->rollBack();
  12.  }

  • author: Qiang Xue <qiang.xue@gmail.com>
  • version: $Id: TDbTransaction.php 2996 2011-06-20 15:24:57Z ctrlaltca@gmail.com $
  • since: 3.0

Located in /Data/TDbTransaction.php (line 42)

TComponent
   |
   --TDbTransaction
Method Summary
TDbTransaction __construct (TDbConnection $connection)
void commit ()
boolean getActive ()
void rollback ()
void setActive (boolean $value)
Methods
Constructor __construct (line 52)

Constructor.

  • see: TDbConnection::beginTransaction
  • access: public
TDbTransaction __construct (TDbConnection $connection)
  • TDbConnection $connection: the connection associated with this transaction
commit (line 62)

Commits a transaction.

  • throws: TDbException if the transaction or the DB connection is not active.
  • access: public
void commit ()
getActive (line 99)
  • return: whether this transaction is active
  • access: public
boolean getActive ()
getConnection (line 91)
  • return: the DB connection for this transaction
  • access: public
TDbConnection getConnection ()
rollback (line 77)

Rolls back a transaction.

  • throws: TDbException if the transaction or the DB connection is not active.
  • access: public
void rollback ()
setActive (line 107)
  • access: protected
void setActive (boolean $value)
  • boolean $value: whether this transaction is active

Inherited Methods

Inherited From TComponent

TComponent::addParsedObject()
TComponent::attachEventHandler()
TComponent::canGetProperty()
TComponent::canSetProperty()
TComponent::createdOnTemplate()
TComponent::detachEventHandler()
TComponent::evaluateExpression()
TComponent::evaluateStatements()
TComponent::getEventHandlers()
TComponent::getSubProperty()
TComponent::hasEvent()
TComponent::hasEventHandler()
TComponent::hasProperty()
TComponent::raiseEvent()
TComponent::setSubProperty()
TComponent::__call()
TComponent::__get()
TComponent::__set()
TComponent::__sleep()
TComponent::__wakeup()

Documentation generated on Mon, 25 Jun 2012 14:38:01 +0200 by phpDocumentor 1.4.3