MySQL++ Reference Manual

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# transaction.h

Go to the documentation of this file.

    00001
    00002
    00003
    00004
    00005
    00006
    00007
    00008 /***********************************************************************
    00009  Copyright (c) 2006-2009 by Educational Technology Resources, Inc. and
    00010  (c) 2008 by AboveNet, Inc.  Others may also hold copyrights on code
    00011  in this file.  See the CREDITS.txt file in the top directory of the
    00012  distribution for details.
    00013
    00014  This file is part of MySQL++.
    00015
    00016  MySQL++ is free software; you can redistribute it and/or modify it
    00017  under the terms of the GNU Lesser General Public License as published
    00018  by the Free Software Foundation; either version 2.1 of the License, or
    00019  (at your option) any later version.
    00020
    00021  MySQL++ is distributed in the hope that it will be useful, but WITHOUT
    00022  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    00023  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
    00024  License for more details.
    00025
    00026  You should have received a copy of the GNU Lesser General Public
    00027  License along with MySQL++; if not, write to the Free Software
    00028  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
    00029  USA
    00030 ***********************************************************************/
    00031
    00032 #if !defined(MYSQLPP_TRANSACTION_H)
    00033 #define MYSQLPP_TRANSACTION_H
    00034
    00035 #include "common.h"
    00036
    00037 namespace mysqlpp {
    00038
    00039 #if !defined(DOXYGEN_IGNORE)
    00040 // Make Doxygen ignore this
    00041 class MYSQLPP_EXPORT Connection;
    00042 #endif
    00043
    00045
    00046 class MYSQLPP_EXPORT Transaction
    00047 {
    00048 public:
    00055         enum IsolationLevel {
    00056                 read_uncommitted,
    00057                 read_committed,
    00058                 repeatable_read,
    00059                 serializable
    00060         };
    00061
    00066         // the isolation scope will affect.
    00067         enum IsolationScope {
    00068                 this_transaction,
    00069                 session,
    00070                 global
    00071         };
    00072
    00079         Transaction(Connection& conn, bool consistent = false);
    00080
    00090         Transaction(Connection& conn, IsolationLevel level,
    00091                         IsolationScope scope = this_transaction,
    00092                         bool consistent = false);
    00093
    00102         ~Transaction();
    00103
    00111         void commit();
    00112
    00119         void rollback();
    00120
    00121 private:
    00122         Connection& conn_;
    00123         bool finished_;
    00124 };
    00125
    00126
    00137 class MYSQLPP_EXPORT NoTransaction
    00138 {
    00139 public:
    00141         NoTransaction(Connection&, bool = false)
    00142         {
    00143         }
    00144
    00146         ~NoTransaction() { }
    00147
    00149         void commit() { }
    00150
    00152         void rollback() { }
    00153 };
    00154
    00155 } // end namespace mysqlpp
    00156
    00157 #endif // !defined(MYSQLPP_TRANSACTION_H)
    00158