/home/tetron/hack/vos/libs/vos/extensions/sqlpersist/mysqldb.hh
Go to the documentation of this file.00001 #ifndef _MYSQLDB_HH_
00002 #define _MYSQLDB_HH_
00003
00004 #include <vos/vosconfig.h>
00005 #include <boost/thread/mutex.hpp>
00006 #include <vos/extensions/sqlpersist/sqldb.hh>
00007
00008 #ifdef HAVE_MYSQL_MYSQL_H
00009 #include <mysql/mysql.h>
00010 #else
00011 #error HAVE_MYSQL_MYSQL_H is not defined. Did configure find MySQL?
00012 #endif
00013
00014 namespace VOS {
00015 class MySQLResult : public SQLResult
00016 {
00017 private:
00018 MYSQL* database;
00019 MYSQL_RES* result;
00020 boost::mutex::scoped_lock* lock;
00021 public:
00022 MySQLResult(MYSQL* db, MYSQL_RES* res, boost::mutex::scoped_lock* lock);
00023 virtual ~MySQLResult();
00024 virtual int countRows();
00025 virtual SQLRow* getNextRow();
00026 };
00027
00028 class SQLPERSIST_API MySQLDatabase : public SQLDatabase
00029 {
00030 private:
00031 MYSQL* database;
00032 boost::mutex db_mutex;
00033 public:
00034 MySQLDatabase(const char* hostname = "localhost", const char* username = "root",
00035 const char* password = "", int port = MYSQL_PORT);
00036 virtual ~MySQLDatabase();
00037
00038 virtual SQLResult* query(const char* q, unsigned int len);
00039 virtual bool selectDatabase(const char* db);
00040 virtual std::string lastError();
00041 virtual unsigned int escapeString(char* to, const char* from, unsigned int fromlen);
00042 virtual unsigned int getAffectedRows();
00043 };
00044 }
00045
00046 #endif