Fixed Transaction class.
parent
f208120799
commit
6bc7fd8762
@ -1,12 +1,32 @@
|
||||
#include "transaction.h"
|
||||
|
||||
#include "context.h"
|
||||
|
||||
bool Transaction::m_inTransaction = false;
|
||||
|
||||
Transaction::Transaction()
|
||||
{
|
||||
|
||||
if (!Transaction::m_inTransaction)
|
||||
{
|
||||
m_tr = new odb::transaction(Context::instance().db()->begin());
|
||||
Transaction::m_inTransaction = true;
|
||||
}
|
||||
}
|
||||
|
||||
Transaction::~Transaction()
|
||||
{
|
||||
if (m_tr != NULL)
|
||||
{
|
||||
delete m_tr;
|
||||
Transaction::m_inTransaction = false;
|
||||
}
|
||||
}
|
||||
|
||||
void Transaction::commit()
|
||||
{
|
||||
if (m_tr != NULL)
|
||||
{
|
||||
m_tr->commit();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,20 @@
|
||||
#ifndef TRANSACTION_H
|
||||
#define TRANSACTION_H
|
||||
|
||||
#include <odb/database.hxx>
|
||||
#include <odb/transaction.hxx>
|
||||
|
||||
class Transaction
|
||||
{
|
||||
public:
|
||||
Transaction();
|
||||
~Transaction();
|
||||
|
||||
void commit();
|
||||
|
||||
private:
|
||||
odb::transaction *m_tr;
|
||||
static bool m_inTransaction;
|
||||
};
|
||||
|
||||
#endif // TRANSACTION_H
|
||||
|
Loading…
Reference in New Issue