00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _mysqlconnection_h
00018 #define _mysqlconnection_h
00019
00020 #include <spl/types.h>
00021 #include <spl/Debug.h>
00022
00023 #ifdef _WINDOWS
00024 #include <spl/configwin32.h>
00025 #else
00026 #include <spl/autoconf/config.h>
00027 #endif
00028
00029 #ifdef HAVE_TIME_H
00030 #include <time.h>
00031 #endif
00032 #ifdef HAVE_SYS_TYPE_H
00033 #include <sys/time.h>
00034 #endif
00035
00042 #if defined(HAVE_MYSQL_H) || defined(HAVE_MYSQL_MYSQL_H)
00043
00044 #include <spl/data/Connection.h>
00045 #include <spl/WeakReference.h>
00046
00047 typedef struct _mysqlerror
00048 {
00049 int code;
00050 char errstr[512];
00051 } mysqlerror;
00052
00053 class MySqlConnection;
00054 typedef RefCountPtrCast<MySqlConnection, Connection, ConnectionPtr> MySqlConnectionPtr;
00055 typedef WeakReference<MySqlConnection, MySqlConnectionPtr> MySqlConnectionRef;
00056
00057 REGISTER_TYPEOF( 420, MySqlConnectionPtr );
00058 REGISTER_TYPEOF( 421, MySqlConnectionRef );
00059
00067 class MySqlConnection : public Connection
00068 {
00069 protected:
00070
00071 void *m_mysql;
00072 mysqlerror m_lasterror;
00073 bool m_isopen;
00074
00075 public:
00076 MySqlConnection(const String& serverOrIP, const String& database, const String& uid, const String& pw);
00077 virtual ~MySqlConnection();
00078
00080 virtual void Open();
00081
00083 virtual void Close();
00084
00086 virtual void ChangeDatabase(const String& db);
00087
00088 virtual TransactionPtr BeginTransaction();
00089 virtual CommandPtr CreateCommand();
00090 virtual CommandPtr CreateCommand(const String& cmdText);
00091
00092 virtual int ExecuteNonQuery(const String& sql);
00093 virtual RecordSetPtr ExecuteQuery(const String& sql);
00094
00096 virtual void RegisterThread();
00097
00099 virtual void RegisterThreadExit();
00100
00102 virtual void AllowOutOfOrderCommandParameters(bool allow);
00103
00104 #if defined(DEBUG)
00105 virtual void CheckMem() const;
00106 virtual void ValidateMem() const;
00107 #endif
00108
00109 private:
00110 void FillErrorInfo();
00111 };
00112
00113 REGISTER_TYPEOF( 418, MySqlConnection );
00114
00115 #endif
00116
00119 #endif