query down
This commit is contained in:
@@ -111,23 +111,31 @@ public:
|
||||
return really_result;
|
||||
}
|
||||
|
||||
std::expected<std::map<std::string_view, std::vector<std::string_view>>, std::string_view> Query(std::string_view command){
|
||||
std::expected<std::vector<std::vector<std::string_view>>, std::string_view> Query(std::string_view command){
|
||||
//Not Implemented;
|
||||
std::map<std::string_view, std::vector<std::string_view>> really_result;
|
||||
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){
|
||||
auto row_length = mysql_fetch_lengths(mysql_result);
|
||||
auto field_length = mysql_num_fields(mysql_result);
|
||||
std::vector<std::string_view> temp;
|
||||
while(auto row = mysql_fetch_row(mysql_result)){
|
||||
temp.clear();
|
||||
for(int i=0; i<field_length; i++){
|
||||
if(row[i] != nullptr){
|
||||
temp.emplace_back(row[i]);
|
||||
}else{
|
||||
temp.emplace_back("");
|
||||
}
|
||||
|
||||
}
|
||||
really_result.emplace_back(temp);
|
||||
}
|
||||
|
||||
mysql_free_result(mysql_result);
|
||||
}
|
||||
|
||||
return std::unexpected(get_error_msg());
|
||||
return really_result;
|
||||
}
|
||||
|
||||
bool Execute(std::string_view command){
|
||||
|
||||
Reference in New Issue
Block a user