#include <transaction.h>
Collaboration diagram for mysqlpp::Transaction:
Public Member Functions | |
Transaction (Connection &conn, bool consistent=false) | |
Constructor. | |
~Transaction () | |
Destructor. | |
void | commit () |
Commits the transaction. | |
void | rollback () |
Rolls back the transaction. |
Transaction::Transaction | ( | Connection & | conn, | |
bool | consistent = false | |||
) |
Constructor.
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.
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.