00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef OPEN_MYDB_H
00013 #define OPEN_MYDB_H 1
00014
00015 #include <mysql.h>
00016 #include "openDB.h"
00017 #include "openFields.h"
00018 #include "mySqlTypeMap.h"
00019
00020
00021
00022
00023
00024 class mySqlDB: public openDB
00025 {
00026 protected:
00027
00028 string m_strErrors;
00029 string host;
00030 string uid;
00031 string pwd;
00032 string db;
00033 unsigned int port;
00034 string socket;
00035 const char * pchSocket;
00036 unsigned int flags;
00037
00038
00039 MYSQL * connection, mysql;
00040 bool transactioning;
00041
00042 virtual bool parseConnection( string & strConnection );
00043 virtual openCMD * createCommand();
00044 virtual openRS * createRecordset();
00045
00046 public:
00047
00048 mySqlDB( string strConnection );
00049 virtual ~mySqlDB();
00050 virtual dbProvider getProvider( void );
00051
00052 bool error( int state = 0 );
00053 string errorString( void ){ return m_strErrors; }
00054 MYSQL * getConnection( void )
00055 {
00056 return connection;
00057 }
00058 };
00059
00060
00061
00062
00063
00064
00065 class mySqlCMD: public openCMD
00066 {
00067 protected:
00068 mySqlDB * poDB;
00069
00070
00071 int state;
00072 size_t rows;
00073
00074 public:
00075
00076 mySqlCMD( openDB & idb );
00077 virtual ~mySqlCMD();
00078
00079
00080 virtual bool execute( string );
00081 virtual int resultId( void );
00082
00083 virtual bool beginTransaction();
00084 virtual bool commit();
00085 virtual bool rollback();
00086 };
00087
00088
00089 const size_t maxColLen = 512;
00090
00091
00092
00093
00094 class mySqlRS : public openRS
00095 {
00096
00097 protected:
00098 mySqlDB * poDB;
00099
00100
00101 int state;
00102 size_t rows;
00103 MYSQL_RES * result;
00104
00105
00106 my_col_infoVector colInfo;
00107 mysqlMap colMap;
00108
00109
00110 bool beginTransaction();
00111 bool commit();
00112
00113 public:
00114 mySqlRS( openDB & idb );
00115 virtual ~mySqlRS();
00116
00117 virtual bool open( string sql );
00118 virtual bool close( void );
00119 virtual bool next( int rows = 1 );
00120 virtual bool previous( int rows = 1 );
00121
00122 };
00123
00124 #endif