Fix getTable() in where condition commands

queue
marcelb 1 year ago
parent 04f8489cf3
commit 701ebef06f
  1. 3
      src/mysql.cpp
  2. 2
      test/test.cpp
  3. BIN
      test/test.o

@ -195,10 +195,11 @@ bool mySQL::change(const string sql_command) {
string mySQL::getTable(const string req) {
size_t from = req.find("FROM") < req.find("from") ? req.find("FROM") : req.find("from");
size_t ends = req.find(" ", from+5) < req.length() ? req.find(" ", from+5) : req.length();
if (from > req.length()) {
return "";
}
string table = req.substr(from+5, req.find(" ", from+5));
string table = req.substr(from+5, ends-from-5);
return table;
}

@ -10,7 +10,7 @@ int main() {
try {
auto res = mydb.query("SELECT * FROM records");
auto res = mydb.query("SELECT * FROM records WHERE enabled = 1;");
for (auto i : res) {
for (auto j: i.second) {

Binary file not shown.
Loading…
Cancel
Save