📄 database.cpp
字号:
#include "DataBase.h"
DataBase::DataBase(string host, string user, string pwd, string dbname)
{
this->host = host;
this->user =user;
this->pwd = pwd;
this->dbname = dbname;
}
DataBase::~DataBase()
{
}
int DataBase::Connectdb(mysqlpp::Connection *conn, string encode){
if (!conn->connect(NULL, (this->host).c_str(), (this->user).c_str(), (this->pwd).c_str())) {
return 1;
}
if(!conn->select_db(this->dbname.c_str())) {
return 2;
}
string sql = "set names " + encode;
mysqlpp::Query query = conn->query(sql.c_str());
if(!query.execute()) {
return 3;
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -