32 lines
863 B
C
32 lines
863 B
C
|
#ifndef __MY_OPERATE_MYSQL__
|
|||
|
#define __MY_OPERATE_MYSQL__
|
|||
|
|
|||
|
#include <string>
|
|||
|
#include <mysql_connection.h>
|
|||
|
|
|||
|
|
|||
|
class OpDatabase
|
|||
|
{
|
|||
|
protected:
|
|||
|
OpDatabase();
|
|||
|
public:
|
|||
|
~OpDatabase();
|
|||
|
static OpDatabase* getInstance();
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>MD5ֵ
|
|||
|
static std::string CalculateMD5(const std::string& data);
|
|||
|
|
|||
|
void CloseDatabase();
|
|||
|
bool OpenDatabase(const std::string& server = "tcp://127.0.0.1:3306", const std::string& dbuser = "root", const std::string& database="hjems");
|
|||
|
void InsertMessage(const std::string& ts, const std::string& msg_type, const std::string& fsu, const std::string& content, int topic, int dev_id);
|
|||
|
|
|||
|
bool queryUser(const std::string& user_id, const std::string& passwd_md5, std::string& jsonResult);
|
|||
|
protected:
|
|||
|
//std::unique_ptr<sql::Connection> m_pDbConnection;
|
|||
|
sql::Connection* m_pDbConnection;
|
|||
|
private:
|
|||
|
static OpDatabase m_instance;
|
|||
|
};
|
|||
|
|
|||
|
#endif
|