blob: fd02c456b6fe8c15e7d30f90f2aea8141b6284fd (
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
|
#ifndef __M_SQL_H__
#define __M_SQL_H__
using namespace std;
#include <string>
#include <vector>
#define SQL_RESULT 1
#define SQL_COUNT 2
#define SQL_ROW 3
#define SQL_ERROR 4
#define SQL_END 5
#define SQL_DONE 6
#define SQL_OK 7
// SQLRequest is inherited from a basic Request object
// so that we can neatly pass information around the
// system.
class SQLRequest
{
protected:
long conn_id;
int request_type;
std::string thisquery;
public:
SQLRequest(int qt, long cid, std::string query)
{
this->SetQueryType(qt);
this->SetConnID(cid);
this->SetQuery(query);
}
void SetConnID(long id)
{
conn_id = id;
}
long GetConnID()
{
return conn_id;
}
void SetQueryType(int t)
{
request_type = t;
}
int GetQueryType()
{
return request_type;
}
void SetQuery(std::string query)
{
thisquery = query;
}
std::string GetQuery()
{
return thisquery;
}
};
// Upon completion, an SQLRequest returns an SQLResponse.
class SQLResult
{
protected:
int resptype;
unsigned long count;
std::string error;
std::map<std::string,std::string> row;
public:
void SetRow(std::map<std::string,std::string> r)
{
row = r;
}
std::string GetField(std::string field)
{
std::map<std::string,std::string>::iterator iter = row.find(field);
if (iter == row.end()) return "";
return iter->second;
}
void SetType(int rt)
{
resptype = rt;
}
void SetError(std::string err)
{
error = err;
}
int GetType()
{
return resptype;
}
std::string GetError()
{
return error;
}
void SetCount(unsigned long c)
{
count = c;
}
unsigned long GetCount()
{
return count;
}
};
#endif
|