Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

mysqlpp::Transaction Class Reference

Helper object for creating exception-safe SQL transactions. More...

#include <transaction.h>

Collaboration diagram for mysqlpp::Transaction:

Collaboration graph
[legend]
List of all members.

Public Methods

MYSQLPP_EXPORT Transaction (Connection &conn, bool consistent=false)
 Constructor.

MYSQLPP_EXPORT ~Transaction ()
 Destructor.

MYSQLPP_EXPORT void commit ()
 Commits the transaction.

MYSQLPP_EXPORT void rollback ()
 Rolls back the transaction.


Detailed Description

Helper object for creating exception-safe SQL transactions.


Constructor & Destructor Documentation

Transaction::Transaction Connection   conn,
bool    consistent = false
 

Constructor.

Parameters:
conn  The connection we use to manage the transaction set
consistent  Whether to use "consistent snapshots" during the transaction. See the documentation for "START TRANSACTION" in the MySQL manual for more on this.

Transaction::~Transaction  
 

Destructor.

If the transaction has not been committed or rolled back by the time the destructor is called, it is rolled back. This is the right thing because one way this can happen is if the object is being destroyed as the stack is unwound to handle an exception. In that instance, you certainly want to roll back the transaction.


Member Function Documentation

void Transaction::commit  
 

Commits the transaction.

This commits all updates to the database using the connection we were created with since this object was created. This is a no-op if the table isn't stored using a transaction-aware storage engine. See CREATE TABLE in the MySQL manual for details.

void Transaction::rollback  
 

Rolls back the transaction.

This abandons all SQL statements made on the connection since this object was created. This only works on tables stored using a transaction-aware storage engine. See CREATE TABLE in the MySQL manual for details.


The documentation for this class was generated from the following files:
Generated on Fri Mar 24 14:05:13 2006 for MySQL++ by doxygen1.2.18