tntdb::Transaction Class Reference

The class Transaction monitors the state of a transaction on a database connection. More...

#include <tntdb/transaction.h>

Public Member Functions

 Transaction (const Connection &db_, bool starttransaction=true)
 Create a Transaction object.
 ~Transaction ()
 Roll back transaction if still active.
const ConnectiongetConnection () const
ConnectiongetConnection ()
void begin ()
 Start a new transaction. If there is an active transaction, it is rolled back first.
void commit ()
 Commit the current transaction.
void rollback ()
 Roll back the current transaction.
void lockTable (const std::string &tableName, bool exclusive=true)
 Lock the specified table.

Detailed Description

The class Transaction monitors the state of a transaction on a database connection.

The constructor by default starts a transaction on the database. The transaction state is held in the class. The destructor rolls back the transaction if it isn't explicitely commited or rolled back.

Constructor & Destructor Documentation

tntdb::Transaction::Transaction ( const Connection db_,
bool  starttransaction = true 
)

Create a Transaction object.

tntdb::Transaction::~Transaction ( )

Roll back transaction if still active.

Member Function Documentation

void tntdb::Transaction::begin ( )

Start a new transaction. If there is an active transaction, it is rolled back first.

void tntdb::Transaction::commit ( )

Commit the current transaction.

If there is no active transaction, nothing is done. The transaction state is reset.

const Connection& tntdb::Transaction::getConnection ( ) const
inline
Connection& tntdb::Transaction::getConnection ( )
inline
void tntdb::Transaction::lockTable ( const std::string &  tableName,
bool  exclusive = true 
)

Lock the specified table.

Locks are released when the transaction is committed or rolled back either explicitly or implicitly by the destructor.

void tntdb::Transaction::rollback ( )

Roll back the current transaction.

If there is no active transaction, nothing is done. The transaction state is reset.


The documentation for this class was generated from the following file: