
对应部分代码如下
map<string, string>kv;//kv(key value)更加灵活
kv.insert(make_pair("name", "image_update001.png"));
kv.insert(make_pair("size", "5000"));
string where = "where id=1";
string temp = "";
//制作迭代器
for (auto ptr = kv.begin(); ptr != kv.end(); ptr++)
{
temp += "`";
temp += ptr->first;
temp += "`='";
temp += ptr->second;
temp += "',";
}
temp += "id=id";
string sql3 = "update t_image set";
sql3 += temp;
sql3 += where;
int ff = mysql_query(&mysql, sql3.c_str());
if (ff == 0)
{
int count = mysql_affected_rows(&mysql);
cout << "update mysql_affected_rows" << count << endl;
}
else {
cout << "update failed!" << mysql_error(&mysql) << endl;
}

