cutelyst 3.9.1
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
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 QSqlDatabase &database)
 Transaction (const QString &databaseName=QString())
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() [1/2]

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.

◆ Transaction() [2/2]

Sql::Transaction::Transaction ( const QSqlDatabase & database)

Definition at line 279 of file sql.cpp.

◆ ~Transaction()

Sql::Transaction::~Transaction ( )

Definition at line 285 of file sql.cpp.

Member Function Documentation

◆ commit()

bool Sql::Transaction::commit ( )

Definition at line 297 of file sql.cpp.

◆ rollback()

bool Sql::Transaction::rollback ( )

Definition at line 304 of file sql.cpp.

◆ transaction()

bool Sql::Transaction::transaction ( ) const

Definition at line 292 of file sql.cpp.