Compare commits
4 Commits
c2d88355d1
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 13396e0cab | |||
| d293180eb1 | |||
| ea90ef1398 | |||
| 458e55868e |
@@ -78,15 +78,26 @@ public:
|
|||||||
SqlConnection& operator=(const SqlConnection& other) = delete;
|
SqlConnection& operator=(const SqlConnection& other) = delete;
|
||||||
|
|
||||||
SqlConnection(SqlConnection&& other){
|
SqlConnection(SqlConnection&& other){
|
||||||
other.Close();
|
this->ip = std::move(other.ip);
|
||||||
this->Connect(other.ip, other.port, other.username, other.password, other.database_name);
|
this->port = std::move(other.port);
|
||||||
|
this->username = std::move(other.username);
|
||||||
|
this->password = std::move(other.password);
|
||||||
|
this->database_name = std::move(other.database_name);
|
||||||
|
this->mysql_client = other.mysql_client;
|
||||||
|
mysql_init(&(other.mysql_client));
|
||||||
}
|
}
|
||||||
|
|
||||||
SqlConnection& operator=(SqlConnection&& other){
|
SqlConnection& operator=(SqlConnection&& other){
|
||||||
if(this != &other){
|
if(this != &other){
|
||||||
auto temp = SqlConnection{};
|
this->Close();
|
||||||
temp.Connect(other.ip, other.port, other.username, other.password, other.database_name);
|
this->ip = std::move(other.ip);
|
||||||
other.Close();
|
this->port = std::move(other.port);
|
||||||
|
this->username = std::move(other.username);
|
||||||
|
this->password = std::move(other.password);
|
||||||
|
this->database_name = std::move(other.database_name);
|
||||||
|
this->mysql_client = other.mysql_client;
|
||||||
|
mysql_init(&other.mysql_client);
|
||||||
|
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -153,9 +164,9 @@ public:
|
|||||||
return std::unexpected(get_error_msg());
|
return std::unexpected(get_error_msg());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::expected<bool> Execute(std::string_view command){
|
std::expected<bool, std::string_view> Execute(std::string_view command){
|
||||||
auto res = mysql_query(&mysql_client, command.data());
|
auto res = mysql_query(&mysql_client, command.data());
|
||||||
if(!res)
|
if(res)
|
||||||
return std::unexpected(get_error_msg());
|
return std::unexpected(get_error_msg());
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user