实时更新数据库
//更新数据库 bool VCManageDatabase::updateObjOneAttribute(QString keyParam, QString valueParam, int userIDParam) { if (!databaseIndex.isOpen()) { qDebug() << "fail to connect mysql:" << databaseIndex.lastError().text(); bool success1 = connectMYSQL(); } if (databaseIndex.isOpen()) { QSqlQuery query_sql = QSqlQuery(databaseIndex); QString query_str_sql1 = "update table set "; query_str_sql1.append(keyParam).append("='").append(valueParam).append("' "); query_str_sql1.append(" where id= ").append(QString::number(userIDParam)); qDebug() << "sql:" << query_str_sql1; bool retb = query_sql.exec(query_str_sql1); return retb; } return false; }