maybe written like this:
Code: Select all
try
{
std::ostringstream sql;
sql << "Select Id from " << ITEMS_TBL_NAME
<< " Where Id = " << id;
mDb->execSql(sql.str());
sql.str("");
if (mDb->getModifiedRows())
{
sql << "UPDATE " << ITEMS_TBL_NAME
<< " SET name = '" << mDb->escapeSQL(name) << "', "
<< " description = '" << mDb->escapeSQL(desc) << "', "
<< " image = '" << image << "', "
<< " weight = " << weight << ", "
<< " itemtype = '" << type << "', "
<< " effect = '" << mDb->escapeSQL(eff) << "', "
<< " dyestring = '" << dye << "' "
<< " WHERE id = " << id;
mDb->execSql(sql.str());
}
else
{
if (mDb->getModifiedRows() == 0)
{
sql.clear();
sql.str("");
sql << "INSERT INTO " << ITEMS_TBL_NAME
<< " VALUES ( " << id << ", '" << name << "', '"
<< desc << "', '" << image << "', " << weight << ", '"
<< type << "', '" << eff << "', '" << dye << "' )";
mDb->execSql(sql.str());
}
}
itmCount++;
}
catch (dal::DbSqlQueryExecFailure const &e)
{
utils::Logger::log("execSQL error:%s" ,e.what());
}