SEGS  0.6.1-develop [39915b3b]
Super Entity Game Server
Database.h
Go to the documentation of this file.
1 /*
2  * SEGS - Super Entity Game Server
3  * http://www.segs.io/
4  * Copyright (c) 2006 - 2019 SEGS Team (see AUTHORS.md)
5  * This software is licensed under the terms of the 3-clause BSD License. See LICENSE.md for details.
6  */
7 
8 #pragma once
9 
10 #include <QtSql/QSqlDatabase>
12 {
13  QSqlDatabase &m_db;
14  bool proper_commit = false;
15 public:
16  DbTransactionGuard(QSqlDatabase &db) : m_db(db)
17  {
18  m_db.transaction();
19  }
20  void commit() {proper_commit=true;}
22  {
23  if(proper_commit)
24  m_db.commit();
25  else
26  m_db.rollback();
27  }
28 
29 };
~DbTransactionGuard()
Definition: Database.h:21
void commit()
Definition: Database.h:20
DbTransactionGuard(QSqlDatabase &db)
Definition: Database.h:16
Definition: Database.h:11