libsqlite3x
2007.10.18
sqlite3x_transaction.cpp
1
/*
2
Copyright (C) 2004-2005 Cory Nelson
3
4
This software is provided 'as-is', without any express or implied
5
warranty. In no event will the authors be held liable for any damages
6
arising from the use of this software.
7
8
Permission is granted to anyone to use this software for any purpose,
9
including commercial applications, and to alter it and redistribute it
10
freely, subject to the following restrictions:
11
12
1. The origin of this software must not be misrepresented; you must not
13
claim that you wrote the original software. If you use this software
14
in a product, an acknowledgment in the product documentation would be
15
appreciated but is not required.
16
2. Altered source versions must be plainly marked as such, and must not be
17
misrepresented as being the original software.
18
3. This notice may not be removed or altered from any source distribution.
19
20
CVS Info :
21
$Author: sgbeal $
22
$Date: 2007/02/25 23:59:06 $
23
$Revision: 1.4 $
24
*/
25
26
#include <sqlite3.h>
27
#include "sqlite3x.hpp"
28
29
namespace
sqlite3x
{
30
31
sqlite3_transaction::sqlite3_transaction(
sqlite3_connection
&con,
bool
start) : con(con),intrans(false) {
32
if
(start)
begin
();
33
}
34
35
sqlite3_transaction::~sqlite3_transaction
() {
36
if
(intrans) {
37
try
{
38
rollback
();
39
}
40
catch
(...) {
41
return
;
42
}
43
}
44
}
45
46
void
sqlite3_transaction::begin
() {
47
con.
executenonquery
(
"begin"
);
48
intrans=
true
;
49
}
50
51
void
sqlite3_transaction::commit
() {
52
con.
executenonquery
(
"commit"
);
53
intrans=
false
;
54
}
55
56
void
sqlite3_transaction::rollback
() {
57
con.
executenonquery
(
"rollback"
);
58
intrans=
false
;
59
}
60
61
}
sqlite3x::sqlite3_connection
Represents a connection to an sqlite3 database.
Definition
sqlite3x.hpp:149
sqlite3x::sqlite3_connection::executenonquery
void executenonquery(const std::string &sql)
Executes a command which is assumed to have a single step and a void result.
Definition
sqlite3x_connection.cpp:196
sqlite3x::sqlite3_transaction::~sqlite3_transaction
~sqlite3_transaction()
If destructed before commit() is called, rollback() is called.
Definition
sqlite3x_transaction.cpp:35
sqlite3x::sqlite3_transaction::begin
void begin()
Starts a transaction.
Definition
sqlite3x_transaction.cpp:46
sqlite3x::sqlite3_transaction::commit
void commit()
Commits a transaction.
Definition
sqlite3x_transaction.cpp:51
sqlite3x::sqlite3_transaction::rollback
void rollback()
Rolls back a transaction with a commit.
Definition
sqlite3x_transaction.cpp:56
sqlite3x
This namespace encapsulates a C++ API wrapper for sqlite3 databases.
Definition
sqlite3x.hpp:120
Generated by
1.12.0