- Home
- About
- Testimonials
- Demos
- Download
- Documentation
- Blogs
- Forum
- Support

Packages: default System System.Caching System.Collections System.Data System.Data.ActiveRecord System.Data.ActiveRecord.Relations System.Data.ActiveRecord.Scaffold System.Data.ActiveReecord.Scaffold.InputBuilder System.Data.Commom.Sqlite System.Data.Common System.Data.Common.Mssql System.Data.Common.Mysql System.Data.Common.Oracle System.Data.Common.Pgsql System.Data.Common.Sqlite System.Data.DataGateway System.Data.SqlMap System.Data.SqlMap.Configuration System.Data.SqlMap.Statements System.Exceptions System.I18N System.IO System.Security System.Util System.Web System.Web.Services System.Web.UI System.Web.UI.ActiveControls System.Web.UI.WebControls System.Web.UI.WebControls.assets System.Xml Classes: TDataSourceConfig TDbColumnCaseMode TDbCommand TDbConnection TDbDataReader TDbNullConversionMode TDbTransaction |
Keyword
# Class TDbTransaction
    TComponent
       |
       --TDbTransaction
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 Author: Qiang Xue <qiang.xue@gmail.com>
Constructor Summary
public | __construct Array Constructor.
Method Summary
void | commit () Commits a transaction.
boolean | getActive ()
TDbConnection | getConnection ()
void | rollback () Rolls back a transaction.
protected void | setActive ( boolean $value)
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()
Constructor Details
## __construct
public __construct | Array
Constructor. See: TDbConnection::beginTransaction
Method Details
## commit
public void commit | ()
Commits a transaction.
Output
Exception
throws | TDbException if the transaction or the DB connection is not active.
## getActive
public boolean getActive | ()
Output
boolean | whether this transaction is active
Exception
## getConnection
public TDbConnection getConnection | ()
Output
TDbConnection | the DB connection for this transaction
Exception
## rollback
public void rollback | ()
Rolls back a transaction.
Output
Exception
throws | TDbException if the transaction or the DB connection is not active.
## setActive
protected void setActive | (boolean $value )
Input
boolean | $value | whether this transaction is active
Output
Exception