00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00025 #ifndef MYSQL_HANDLER_H
00026 #define MYSQL_HANDLER_H
00027
00028 using namespace std;
00029
00030 #include <mysql.h>
00031 #include <list>
00032 #include <map>
00033 #include <iterator>
00034 #include "boss_mysql_exceptions.h"
00035 #include "boss_mysql_result.h"
00036
00037 typedef list< MySQL_Result * > MySQL_ResultList;
00038 typedef map< MYSQL_RES *, MySQL_ResultList > MySQL_ResultMap;
00039 typedef MySQL_ResultMap::iterator MySQL_ResultMapIt;
00040 typedef MySQL_ResultMap::const_iterator MySQL_ResultMapCIt;
00041
00045 class MySQL_Handler {
00046
00047 private:
00048
00049 MYSQL *handle;
00050 MySQL_ResultMap results;
00051
00052 friend class MySQL_Result;
00053
00054 void push_res(MySQL_Result * rclass, MYSQL_RES * rdata);
00055 void pop_res(MySQL_Result * rclass, MYSQL_RES * rdata);
00056
00057 public:
00058
00059 MySQL_Handler::MySQL_Handler() throw(MySQL_ConnectFailed);
00060 MySQL_Handler(const string & user, const string & passwd, const string & database) throw(MySQL_ConnectFailed);
00061 MySQL_Handler(const string & host, const string & user, const string & passwd, const string & database) throw(MySQL_ConnectFailed);
00062 MySQL_Handler::MySQL_Handler(const MySQL_Handler & h);
00063 ~MySQL_Handler();
00064 MySQL_Handler & operator = (const MySQL_Handler & h);
00065
00066 MySQL_Result query(const char * query_string, const bool do_free=false);
00067 MySQL_Result query(const char * query_string, const unsigned & length, const bool do_free=false) throw(MySQL_QueryFailed);
00068
00069 void print(ostream & out) const;
00070 };
00071
00072 #endif