tntdb::Transaction Class Reference

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

`#include <transaction.h>`

Inheritance diagram for tntdb::Transaction:

## Public Member Functions

| Transaction (const Connection &db_, bool starttransaction=true)
| Start a transaction when instructed. More...
| ~Transaction ()
| roll back transaction when still active More...
const Connection & | getConnection () const
Connection & | getConnection ()
void | begin ()
| Starts a new transaction. More...
void | commit ()
| commits the current transaction. More...
void | rollback ()
| rolls back the current transaction. More...
void | lockTable (const std::string &tableName, bool exclusive=true)
| Locks the specified table. More...

## Detailed Description

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

The constructor starts by default a transaction on the database. The transactionstate is hold it the class. The destructor rolls the transaction back, when not explicitely commited or rolled back.

## Constructor & Destructor Documentation

## Transaction()

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

Start a transaction when instructed.

## ~Transaction()

tntdb::Transaction::~Transaction | ( |  | ) |

roll back transaction when still active

## Member Function Documentation

## begin()

void tntdb::Transaction::begin | ( |  | ) |

Starts a new transaction.

If there is a active transaction, it is rolled back first

## commit()

void tntdb::Transaction::commit | ( |  | ) |

commits the current transaction.

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

## lockTable()

void tntdb::Transaction::lockTable | ( | const std::string & | tableName,
|  | bool | exclusive = `true`
| ) |  |

Locks the specified table.

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

## rollback()

void tntdb::Transaction::rollback | ( |  | ) |

rolls back the current transaction.

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

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

- tntdb/transaction.h