00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00022
00023
00024
00025
00026
00027 #ifndef DATABASE_INCLUDED
00028 #define DATABASE_INCLUDED
00029
00030 #ifdef MYSQLPP
00031
00032 #include <mysql++.h>
00033
00034 #include <iostream>
00035 #include <iomanip>
00036 #include <vector>
00037 #include <cstring>
00038
00039 #include "TableParser.h"
00040
00041 class Database : public TableParser{
00042 private:
00043 const char* _host;
00044 const char* _user;
00045 const char* _password;
00046 const char* _database;
00047 unsigned _port;
00048 bool _connected;
00049 mysqlpp::Connection _con;
00050
00051 public:
00052
00053 Database() {_connected = false;}
00054
00055
00056
00057
00058 Database(const char* host,const char* user,const char* password,const char* database,unsigned port=0)
00059 {
00060 _host = host;
00061 _user = user;
00062 _password = password;
00063 _database = database;
00064 _connected = true;
00065 _port = port;
00066 try
00067 {
00068 _con.connect(_database,_host,_user,_password,_port);
00069 }
00070 catch(...)
00071 {
00072 std::cout << "ERROR" << std::endl;
00073 }
00074 }
00075
00076 void setup(const char* host,const char* user,const char* password,const char* database,unsigned port=0)
00077 {
00078 _host = host;
00079 _user = user;
00080 _password = password;
00081 _database = database;
00082 _port = port;
00083 _connected = true;
00084 try
00085 {
00086 _con.connect(_database,_host,_user,_password,_port);
00087 }
00088 catch(...)
00089 {
00090 std::cout << "ERROR" << std::endl;
00091 }
00092 }
00093
00094
00095
00096 void readTable(const char* sqlQuery);
00097 void query(const char* sqlQuery);
00098
00099 void display(void);
00100 };
00101
00102 #endif
00103 #endif