Class 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();
- }
Constructor Summary |
public |
Constructor.
|
Method Summary |
void
|
Commits a transaction.
|
boolean
|
|
TDbConnection
|
|
void
|
Rolls back a transaction.
|
protected
void
|
|
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
Constructor.
See:
TDbConnection::beginTransaction
|
Method Details |
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
Output |
TDbConnection
| the DB connection for this transaction |
Exception |
|
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 |
|
|