MKSQLCpp
0.1
MakeMySQLC++Classes
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Macros
Pages
include
CMySQL.h
Go to the documentation of this file.
1
7
#ifndef __CMySQL_H__
8
#define __CMySQL_H__
9
10
#define DEBUG // comment this out if you do not want normal debugging display.
11
12
#include <mysql.h>
13
#include "
loc_types.h
"
14
15
#define RestrictCopy(StrDst,StrSrc) strncpy(StrDst,(StrSrc==NULL?"NULL":StrSrc),sizeof(StrDst)-1)
16
#define CopyStrValue(dst,sep,src) sprintf(dst,(strcmp(src,"NULL")==0?"%s"sep:"'%s'"sep),src)
17
21
struct
SFieldInfo
22
{
23
const
char
*
name_of_field
;
24
const
char
*
name_of_type
;
25
BOOL
bNullAllowed
;
26
const
char
*
DefaultValue
;
27
BOOL
bAutoIncrement
;
28
BOOL
bPrimary
;
29
BOOL
bIndexKey
;
30
BOOL
bIndex
;
31
BOOL
bUnique
;
32
};
33
37
struct
STableInfo
38
{
39
char
table_name
[81];
40
struct
SFieldInfo
*
fields
;
41
};
42
48
class
CMySQL
49
{
50
MYSQL
mysql
;
51
MYSQL_RES *
res
;
52
53
BOOL
bConnected
;
54
BOOL
bInitialized
;
55
public
:
56
CMySQL
();
57
~CMySQL
();
58
59
const
char
*
GetClientInfo
();
60
61
BOOL
Connect
(
const
char
*host=NULL,
const
char
*user=NULL,
const
char
*passwd=NULL,
const
char
*db=NULL,
uint
port=0,
const
char
*usock=NULL,
uint
clflag=0);
62
BOOL
Close
(
BOOL
bInit);
63
BOOL
Init
();
64
BOOL
SelectDB
(
const
char
*db);
65
const
char
*
Stat
();
66
67
BOOL
Query
(
char
*str);
68
BOOL
RealQuery
(
char
*str,
uint
len);
69
70
BOOL
CreateDatabase
(
const
char
*db);
71
BOOL
DropDatabase
(
const
char
*db);
72
int
GetAffectedRows
();
73
74
MYSQL_RES *
StoreResult
();
75
MYSQL_RES *
UseResult
();
76
MYSQL_ROW
FetchRow
(MYSQL_RES *
res
);
77
78
void
FreeResult
(MYSQL_RES *
res
);
79
int
NumRows
(MYSQL_RES *
res
);
80
int
NumFields
(MYSQL_RES *
res
);
81
82
void
DataSeek
(MYSQL_RES *result,
ulong
offset);
89
void
DataSeek
(
ulong
offset) {
DataSeek
(
res
,offset); };
90
101
const
char
*
GetError
() {
return
mysql_error(&
mysql
); };
117
uint
GetErrno
() {
return
mysql_errno(&
mysql
); };
118
119
BOOL
CreateTable
(
const
char
*name,
struct
SFieldInfo
**sinfo);
134
BOOL
CreateTable
(
struct
STableInfo
*table) {
return
CreateTable
(table->
table_name
,&table->
fields
); };
135
136
MYSQL_RES *
ListTables
(
const
char
*wild=NULL);
137
138
BOOL
TableExists
(
const
char
*name);
153
BOOL
TableExists
(
struct
STableInfo
*table) {
return
TableExists
(table->
table_name
); };
154
155
BOOL
DropTable
(
const
char
*name,
BOOL
bCascade=
FALSE
,
BOOL
bRestrict=
FALSE
);
172
BOOL
DropTable
(
struct
STableInfo
*table,
BOOL
bCascade=
FALSE
,
BOOL
bRestrict=
FALSE
)
173
{
return
DropTable
(table->
table_name
,bCascade,bRestrict); };
174
175
BOOL
InsertRow
(
const
char
*name,
struct
SFieldInfo
**sinfo,
const
char
*Values);
192
BOOL
InsertRow
(
struct
STableInfo
*table,
const
char
*Values,
int
ValSize)
193
{
return
InsertRow
(table->
table_name
,&table->
fields
,Values); };
194
195
long
GetTotalCount
(
struct
STableInfo
*table);
196
};
197
198
#endif
/* __CMySQL_H__ */
Generated by
1.8.1.1