tntdb 1.4
|
The class Transaction monitors the state of a transaction on a database connection. More...
#include <transaction.h>
Public Member Functions | |
Transaction (const Connection &db_, bool starttransaction=true) | |
Create a Transaction object. | |
~Transaction () | |
Roll back transaction if still active. | |
const Connection & | getConnection () const |
Connection & | getConnection () |
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. | |
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.
tntdb::Transaction::Transaction | ( | const Connection & | db_, |
bool | starttransaction = true ) |
Create a Transaction object.
tntdb::Transaction::~Transaction | ( | ) |
Roll back transaction if still active.
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.
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.