MySQL++ Reference Manual

MySQL++: transaction.h Source File

MySQL++ 3.2.4

transaction.h
Go to the documentation of this file.
1
8 /***********************************************************************
9 Copyright (c) 2006-2009 by Educational Technology Resources, Inc. and
10 (c) 2008 by AboveNet, Inc. Others may also hold copyrights on code
11 in this file. See the CREDITS.txt file in the top directory of the
12 distribution for details.
13
14 This file is part of MySQL++.
15
16 MySQL++ is free software; you can redistribute it and/or modify it
17 under the terms of the GNU Lesser General Public License as published
18 by the Free Software Foundation; either version 2.1 of the License, or
19 (at your option) any later version.
20
21 MySQL++ is distributed in the hope that it will be useful, but WITHOUT
22 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
24 License for more details.
25
26 You should have received a copy of the GNU Lesser General Public
27 License along with MySQL++; if not, write to the Free Software
28 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
29 USA
30 ***********************************************************************/
31
32 #if !defined(MYSQLPP_TRANSACTION_H)
33 #define MYSQLPP_TRANSACTION_H
34
35 #include "common.h"
36
37 namespace mysqlpp {
38
39 #if !defined(DOXYGEN_IGNORE)
40 // Make Doxygen ignore this
41 class MYSQLPP_EXPORT Connection;
42 #endif
43
45
46 class MYSQLPP_EXPORT Transaction
47 {
48 public:
55 enum IsolationLevel {
56 read_uncommitted,
57 read_committed,
58 repeatable_read,
59 serializable
60 };
61
66 // the isolation scope will affect.
67 enum IsolationScope {
68 this_transaction,
69 session,
70 global
71 };
72
79 Transaction(Connection& conn, bool consistent = false);
80
90 Transaction(Connection& conn, IsolationLevel level,
91 IsolationScope scope = this_transaction,
92 bool consistent = false);
93
102 ~Transaction();
103
111 void commit();
112
119 void rollback();
120
121 private:
122 Connection& conn_;
123 bool finished_;
124 };
125
126
137 class MYSQLPP_EXPORT NoTransaction
138 {
139 public:
141 NoTransaction(Connection&, bool = false)
142 {
143 }
144
146 ~NoTransaction() { }
147
149 void commit() { }
150
152 void rollback() { }
153 };
154
155 } // end namespace mysqlpp
156
157 #endif // !defined(MYSQLPP_TRANSACTION_H)
158
mysqlpp::NoTransaction::commit
void commit()
stub to replace Transaction::commit()
Definition: transaction.h:149
mysqlpp::Transaction::IsolationScope
IsolationScope
Isolation level scopes defined in SQL.
Definition: transaction.h:67
mysqlpp::NoTransaction::rollback
void rollback()
stub to replace Transaction::rollback()
Definition: transaction.h:152
mysqlpp::NoTransaction
Compile-time substitute for Transaction, which purposely does nothing. Use it to instantiate template...
Definition: transaction.h:137
mysqlpp::Transaction::this_transaction
change level for this transaction only
Definition: transaction.h:68
mysqlpp::Transaction::read_committed
only read rows committed by other transactions
Definition: transaction.h:57
mysqlpp
Definition: autoflag.h:31
mysqlpp::Connection
Manages the connection to the database server.
Definition: connection.h:59
mysqlpp::Transaction::read_uncommitted
allow "dirty reads" from other transactions
Definition: transaction.h:56
mysqlpp::Transaction
Helper object for creating exception-safe SQL transactions.
Definition: transaction.h:46
mysqlpp::NoTransaction::~NoTransaction
~NoTransaction()
Destructor.
Definition: transaction.h:146
mysqlpp::Transaction::IsolationLevel
IsolationLevel
Transaction isolation levels defined in SQL.
Definition: transaction.h:55
mysqlpp::Transaction::repeatable_read
other transactions do not affect repeated reads in this transaction
Definition: transaction.h:58
mysqlpp::NoTransaction::NoTransaction
NoTransaction(Connection &, bool=false)
Constructor.
Definition: transaction.h:141
mysqlpp::Transaction::session
change level for all transactions in this session
Definition: transaction.h:69
common.h
This file includes top-level definitions for use both internal to the library, and outside it...