blob: 37f78da8d24e2e93a5654d6caa3f036dba975cb3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
// -*- C++ -*-
//=============================================================================
/**
* @file Query.h
*
* $Id$
*
* @author James H. Hill
*/
//=============================================================================
#ifndef _ADBC_SQLITE_QUERY_H_
#define _ADBC_SQLITE_QUERY_H_
#include "Record.h"
#include "Parameter_List.h"
#include "adbc/Query.h"
// Forward decl.
struct sqlite3_stmt;
namespace ADBC
{
namespace SQLite
{
// Forward decl.
class Connection;
/**
* @class Query
*
* Implemenation of the Query class for SQLite
*/
class ADBC_SQLITE_Export Query : public ::ADBC::Query
{
// Friend decl.
friend class Record;
// Friend decl.
friend class Parameter_List;
// Friend decl.
friend class Parameter;
public:
/// Default constructor
Query (Connection & parent);
/// Destructor
virtual ~Query (void);
/**
* Prepare a statement for execution.
*
* @param[in] query NULL-terminated query string.
*/
virtual void prepare (const char * query);
/**
* Prepare a statement for execution.
*
* @param[in] query NULL-terminated query string.
*/
virtual void prepare (const char * query, size_t len);
/**
* Directly execute a database query.
*
* @param[in] query NULL-terminated query string.
*/
virtual void execute_no_record (const char * query);
/// Execute an already prepared query.
virtual void execute_no_record (void);
/**
* Execute a query. This method is useful with the query is known
* to return results that will consist of multiple data rows, and
* columns. The client has the responsibility of delete the record
* once its done with it.
*
* @return Pointer to a record.
*/
virtual Record * execute (const char * query);
/**
* Execute a prepared query. This method is useful with the query is
* known to return results that will consist of multiple data rows,
* and columns. The client has the responsibility of delete the record
* once its done with it.
*
* @return Pointer to a record.
*/
virtual Record * execute (void);
/// Cancel the current query.
virtual void cancel (void);
/**
* Get the last insert id. This method is only value if an
* insert was made to a table with an \a auto_increment field.
*
* @return The last id inserted.
*/
virtual long last_insert_id (void);
virtual Parameter_List & parameters (void);
virtual const Parameter_List & parameters (void) const;
/// Reset the query string.
virtual void reset (void);
private:
void finalize (void);
/// Owner of the query.
Connection & parent_;
/// Actual SQLite3 statement.
::sqlite3_stmt * stmt_;
bool needs_reseting_;
/// Collection of parameters for this query.
Parameter_List params_;
};
}
}
#if defined (__ADBC_INLINE__)
#include "Query.inl"
#endif
#endif // !defined _ADBC_SQLITE_QUERY_H_
|