-
Notifications
You must be signed in to change notification settings - Fork 3
/
database.h
executable file
·53 lines (44 loc) · 1.3 KB
/
database.h
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
/**************
* File Name: database.h
* Author: G. J. Krafsig
* Date: June 28, 2007
* Purpose: header file for database implementation
**************/
#ifndef DATABASE_H
#define DATABASE_H
#include <allegro.h>
#include <winalleg.h>
#include "mysql/mysql.h"
/**************
* Database Error Definitions
**************/
#define SUCCESS 200
#define ERR201 201
#define ERR202 202
#define ERR203 203
#define MAX_QUERY_LEN 500
class database
{
public:
//class constructor
database();
//connection & disconnect
int openConnection(char *host, char *db, char *user, char *pass); //connect to the database
bool disconnect(); //disconnect from the database
//querying
MYSQL_RES *query(char *query); //return result set
char *stringQuery(char *query); //return string
int intQuery(char *query); //return an integer
bool boolQuery(char *query); //return a boolean
bool updateQuery(char *query); //updates, returns true if update went through
//free the query results
bool free();
private:
MYSQL *sock;
MYSQL_RES *result;
MYSQL_ROW row;
MYSQL_FIELD *field;
char *qbuf[MAX_QUERY_LEN];
};
char *dberror(int errorcode); //return a string for this error message
#endif