I have this simple code:
std::stringstream del;
int ret = 0;
del<<"DELETE FROM 'database_name' WHERE id=\""<<id<<"\""; //id is a parameter of the function
std::string query = del.str();
const char* ch_q = query.c_str();
ret = mysql_query(conn, ch_q);
if(ret == 0)
{
std::cout<<"Record deleted successfully"<<std::endl;
return true;
}else{
std::cout<<"Failed to delete record"<<std::endl;
return false;
}
The id
row in the database has a type of TEXT
and is a PRIMARY KEY
Every time I run the code, it fails to delete the element.