Compare commits
6 Commits
ce32948c67
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 13396e0cab | |||
| d293180eb1 | |||
| ea90ef1398 | |||
| 458e55868e | |||
| c2d88355d1 | |||
| a1bda53ca5 |
@@ -1,3 +1,4 @@
|
||||
#include <exception>
|
||||
#define DEBUG
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -77,15 +78,26 @@ public:
|
||||
SqlConnection& operator=(const SqlConnection& other) = delete;
|
||||
|
||||
SqlConnection(SqlConnection&& other){
|
||||
other.Close();
|
||||
this->Connect(other.ip, other.port, other.username, other.password, other.database_name);
|
||||
this->ip = std::move(other.ip);
|
||||
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){
|
||||
if(this != &other){
|
||||
auto temp = SqlConnection{};
|
||||
temp.Connect(other.ip, other.port, other.username, other.password, other.database_name);
|
||||
other.Close();
|
||||
this->Close();
|
||||
this->ip = std::move(other.ip);
|
||||
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;
|
||||
}
|
||||
@@ -126,7 +138,6 @@ public:
|
||||
}
|
||||
|
||||
std::expected<std::vector<std::vector<std::string_view>>, std::string_view> Query(std::string_view command){
|
||||
//Not Implemented;
|
||||
std::vector<std::vector<std::string_view>> really_result;
|
||||
mysql_query(&mysql_client, command.data());
|
||||
if(auto mysql_result = mysql_store_result(&mysql_client); mysql_result != nullptr){
|
||||
@@ -153,9 +164,11 @@ public:
|
||||
return std::unexpected(get_error_msg());
|
||||
}
|
||||
|
||||
bool Execute(std::string_view command){
|
||||
//Not Implemented;
|
||||
return false;
|
||||
std::expected<bool, std::string_view> Execute(std::string_view command){
|
||||
auto res = mysql_query(&mysql_client, command.data());
|
||||
if(res)
|
||||
return std::unexpected(get_error_msg());
|
||||
return res;
|
||||
}
|
||||
|
||||
std::vector<std::string_view> get_tables(){
|
||||
|
||||
Reference in New Issue
Block a user