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. }

  • since: 3.0
  • version: $Id: TDbTransaction.php 1550 2006-12-03 23:14:20Z xue $
  • author: Qiang Xue <qiang.xue@gmail.com>

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.

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

Commits a transaction.

  • access: public
  • throws: TDbException if the transaction or the DB connection is not active.
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.

  • access: public
  • throws: TDbException if the transaction or the DB connection is not active.
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::__get()
TComponent::__set()

Documentation generated on Mon, 21 Apr 2008 11:34:54 -0400 by phpDocumentor 1.3.0RC4