forked from pocoproject/poco
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStatementExecutor.h
More file actions
99 lines (71 loc) · 1.72 KB
/
StatementExecutor.h
File metadata and controls
99 lines (71 loc) · 1.72 KB
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
//
// StatementExecutor.h
//
// Library: Data/MySQL
// Package: MySQL
// Module: StatementExecutor
//
// Definition of the StatementExecutor class.
//
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef Data_MySQL_StatementHandle_INCLUDED
#define Data_MySQL_StatementHandle_INCLUDED
#include <mysql.h>
#include "Poco/Data/MySQL/MySQLException.h"
namespace Poco {
namespace Data {
namespace MySQL {
class StatementExecutor
/// MySQL statement executor.
{
public:
enum State
{
STMT_INITED,
STMT_COMPILED,
STMT_EXECUTED
};
explicit StatementExecutor(MYSQL* mysql);
/// Creates the StatementExecutor.
~StatementExecutor();
/// Destroys the StatementExecutor.
int state() const;
/// Returns the current state.
void prepare(const std::string& query);
/// Prepares the statement for execution.
void bindParams(MYSQL_BIND* params, std::size_t count);
/// Binds the params.
void bindResult(MYSQL_BIND* result);
/// Binds result.
void execute();
/// Executes the statement.
bool fetch();
/// Fetches the data.
bool fetchColumn(std::size_t n, MYSQL_BIND *bind);
/// Fetches the column.
int getAffectedRowCount() const;
operator MYSQL_STMT* ();
/// Cast operator to native handle type.
private:
StatementExecutor(const StatementExecutor&);
StatementExecutor& operator=(const StatementExecutor&);
private:
MYSQL* _pSessionHandle;
MYSQL_STMT* _pHandle;
int _state;
std::size_t _affectedRowCount;
std::string _query;
};
//
// inlines
//
inline StatementExecutor::operator MYSQL_STMT* ()
{
return _pHandle;
}
} } } // namespace Poco::Data::MySQL
#endif // Data_MySQL_StatementHandle_INCLUDED