## 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:

     try
     {
        $transaction=$connection->beginTransaction();
        $connection->createCommand($sql1)->execute();
        $connection->createCommand($sql2)->execute();
        //.... other SQL executions
            $transaction->commit();
     }
     catch(Exception $e)
     {
        $transaction->rollBack();
     }

- 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 ()
TDbConnection getConnection ()
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