4
4
* Copyright (C) 2009 Tim Marston <edam@waxworlds.org>
6
* This file is part of sqlite3cc (hereafter referred to as "this program").
7
* See http://www.waxworlds.org/edam/software/sqlite3cc for more information.
6
* This file is part of sqlitepp (hereafter referred to as "this program").
7
* See http://www.waxworlds.org/edam/software/sqlitepp for more information.
9
9
* This program is free software: you can redistribute it and/or modify
10
10
* it under the terms of the GNU Lesser General Public License as published
20
20
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23
#ifndef SQLITE3CC_COMMAND_H_
24
#define SQLITE3CC_COMMAND_H_
27
#include <sqlite3cc/basic_statement.h>
27
#include "statement.hpp"
42
public detail::basic_statement
44
44
//______________________________________________________________________________
49
* Constructor that provides a connection upon which to act and the SQL
51
* @param connection a reference to a connection
49
* Constructor that provides the SQL statement to execute
52
50
* @param sql an SQL statement in UTF-8
55
connection &connection,
56
const std::string &sql );
59
* Constructor that provides a connection upon which to act.
60
* @param connection a reference to a connection
63
connection &connection );
54
const std::string &sql )
56
statement( database, sql )
65
59
//______________________________________________________________________________
66
60
// public interface
70
* Prepare an SQL statement.
71
* @param sql an SQL statement in UTF-8
72
* @returns an sqlite error code
73
* @see sqlite3_prepare_v2()
76
const std::string &sql );
79
* Step through one execution cycle of the SQL statement. If this is an SQL
80
* statement that doesn't return any rows, only one cycle is required,
81
* otherwise, each cycle will return another row
82
* @return an sqlite error code
88
64
* Execute the command. This is the same as doing a step().
89
* @return an sqlite error code
90
65
* @see sqlite3_step()
98
* Get the number of changes made by the last successful execution of this
99
* command. This doesn't include changes made in trigger subcontexts.
100
* @return the number of changed rows
101
* @see sqlite3_changes()
109
* Get the number of changes made by the last successful execution of this
110
* command. This includes changes made in all trigger subcontexts.
111
* @return the number of changed rows
112
* @see sqlite3_total_changes()
114
inline int total_changes()
116
return _total_changes;
120
* Get the rowid of the last row inserted via a successful INSERT command
121
* (regardless of whether that is this command or not).
122
* @return the last inserted rowid
124
inline long long last_insert_rowid()
126
return _last_insert_rowid;
129
//______________________________________________________________________________
133
/** non-recursive number of changes made by the last execution */
136
/** recursive number of changes made by the last execution */
139
/** the rowid of the last successful insert command */
140
long long _last_insert_rowid;
149
// template specialisations for detail::basic_statement::operator <<()
151
basic_statement &basic_statement::operator << < detail::exec_t >(
152
const detail::exec_t & );
155
} // namespace detail
158
} // namespace sqlite
161
#endif /* SQLITE3CC_COMMAND_H_ */
78
#endif /* COMMAND_HPP_ */