]> git.sesse.net Git - freerainbowtables/blob - Server Applications/rsearchi/MySQL.h
initial
[freerainbowtables] / Server Applications / rsearchi / MySQL.h
1 #ifndef __MYSQL__H_DB__
2 #define __MYSQL__H_DB__
3 #ifdef WIN32
4         #include <WinSock2.h>
5 #else 
6         #include <sys/socket.h>
7 #define _atoi64 atoll
8
9 #endif
10 #include <mysql.h>
11 #include <errmsg.h>
12 #include <string>
13 #include "Exception.h"
14 #include "Database.h"
15
16
17 class MySQLException : public DatabaseException
18 {
19 public:
20         MySQLException(std::string szErrorMessage, unsigned int nErrorCode) : DatabaseException(szErrorMessage, nErrorCode)     { }
21 };
22
23 class MySQL : public CDatabase
24 {
25 private:
26         MYSQL m_DBHandle;
27         MYSQL_RES *m_LastResult;
28         MYSQL_ROW m_Row;
29
30         std::string m_Servername, m_Username, m_Password, m_Database;
31         int m_Port;
32 public:
33         MySQL(void);
34         MySQL(std::string Servername, std::string Username, std::string Password, std::string Database, int Port = 0);
35         ~MySQL(void);
36
37 public:
38         void Reconnect();
39         void Query(std::string SQLQuery);
40         uint64 Select(std::string SQLQuery);
41         int SelectUnbuffered(std::string SQLQuery);
42         int Fetch(); // TRUE is more data is available
43         void OpenDatabase(std::string Servername, std::string Username, std::string Password, std::string Database, int Port = 0);
44         int GetInt(int Column);
45         __int64 GetInt64(int Column);
46         __int64 GetLastInsertID();
47         __int64 GetAffectedRows();
48         const unsigned char* GetText(int Column);
49         void Escape(std::string&);
50 };
51 #endif
52
53