cutelyst  3.9.1
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
Public Member Functions | List of all members
Cutelyst::Sql::Transaction Class Reference

The Transaction class - This is a helper class to create scoped transactions. More...

#include <sql.h>

Public Member Functions

 Transaction (const QString &databaseName=QString())
 
 Transaction (const QSqlDatabase &database)
 
bool commit ()
 
bool rollback ()
 
bool transaction () const
 

Detailed Description

This is a helper class to create scoped transactions, when you create a local Transaction object it will automatically open a transaction, you can check if the transaction was created successfully by calling transaction(),

Once this object goes out of scope it will automatically rollback the transaction if the transaction was open and commit() was not called. It helps you forgetting to rollback a transaction in case of an error.

Definition at line 29 of file sql.h.

Constructor & Destructor Documentation

◆ Transaction()

Sql::Transaction::Transaction ( const QString databaseName = QString())
explicit

Creates a transaction using the database name that you would pass to Sql::databaseNameThread

Definition at line 273 of file sql.cpp.

References QSqlDatabase::transaction().