Search for usage in LXR

#include <KDbTransaction.h>

Public Types

enum class  CommitOption { None = 0 , IgnoreInactive = 1 }
typedef QFlags< CommitOptionCommitOptions

Public Member Functions

 KDbTransaction ()
 KDbTransaction (const KDbTransaction &trans)
KDbConnectionconnection ()
const KDbConnectionconnection () const
bool isActive () const
bool isNull () const
bool operator!= (const KDbTransaction &other) const
KDbTransactionoperator= (const KDbTransaction &trans)
bool operator== (const KDbTransaction &other) const

Protected Attributes


Detailed Description

This class encapsulates a single database transaction.

The KDbTransaction handle abstracts a database transaction for given database connection. Transaction objects are value-based, implicitly shared.

Lifetime of the transaction object is closely related to a KDbConnection object. Deleting the either instance does not commit or rollback the actual transaction. Use KDbTransactionGuard for automatic commits or rolls back.

See also

Definition at line 43 of file KDbTransaction.h.

Member Typedef Documentation

◆ CommitOptions

Definition at line 68 of file KDbTransaction.h.

Member Enumeration Documentation

◆ CommitOption

enum class KDbTransaction::CommitOption

Options for commiting and rolling back transactions.

See also
KDbConnection::beginTransaction() KDbConnection::rollbackTransaction()
KDbTransactionGuard::commit() KDbTransactionGuard::rollback()

Do not return error for inactive or null transactions when requesting commit or rollback.

Definition at line 63 of file KDbTransaction.h.

Constructor & Destructor Documentation

◆ KDbTransaction() [1/2]

KDbTransaction::KDbTransaction ( )

Constructs a null transaction.

It can be initialized only by KDbConnection.

Definition at line 111 of file KDbTransaction.cpp.

◆ KDbTransaction() [2/2]

KDbTransaction::KDbTransaction ( const KDbTransaction & trans)

Copy constructor.

Definition at line 116 of file KDbTransaction.cpp.

◆ ~KDbTransaction()

KDbTransaction::~KDbTransaction ( )

Definition at line 127 of file KDbTransaction.cpp.

Member Function Documentation

◆ connection() [1/2]

KDbConnection * KDbTransaction::connection ( )

Returns database connection for which the transaction belongs.

nullptr is returned for null transactions.

Definition at line 173 of file KDbTransaction.cpp.

◆ connection() [2/2]

const KDbConnection * KDbTransaction::connection ( ) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.


Definition at line 178 of file KDbTransaction.cpp.

◆ isActive()

bool KDbTransaction::isActive ( ) const

Returns true if transaction is active (i.e.


false also if transaction is uninitialised (null) or not started.
See also

Definition at line 183 of file KDbTransaction.cpp.

◆ isNull()

bool KDbTransaction::isNull ( ) const

Returns true if this transaction is null.

Null implies !isActive().

Definition at line 188 of file KDbTransaction.cpp.

◆ operator!=()

bool KDbTransaction::operator!= ( const KDbTransaction & other) const
true if this transaction is not equal to other; otherwise returns false.

Definition at line 83 of file KDbTransaction.h.

◆ operator=()

KDbTransaction & KDbTransaction::operator= ( const KDbTransaction & trans)

Definition at line 145 of file KDbTransaction.cpp.

◆ operator==()

bool KDbTransaction::operator== ( const KDbTransaction & other) const

Returns true if this transaction is equal to other; otherwise returns false.

Two transactions are equal if they encapsulate the same physical transaction, i.e. copy constructor or assignment operator was used. Two null transaction objects are equal.

Definition at line 168 of file KDbTransaction.cpp.

Member Data Documentation

◆ m_data

KDbTransactionData* KDbTransaction::m_data

Definition at line 118 of file KDbTransaction.h.

The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:21:01 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.