CheckUsedName converted to StringFormat

This commit is contained in:
Arthur Ice 2014-07-08 20:34:44 -07:00 committed by Arthur Ice
parent 8b3afbdf10
commit ec47f8644c

View File

@ -1295,17 +1295,14 @@ bool Database::UpdateName(const char* oldname, const char* newname) {
// If the name is used or an error occurs, it returns false, otherwise it returns true // If the name is used or an error occurs, it returns false, otherwise it returns true
bool Database::CheckUsedName(const char* name) bool Database::CheckUsedName(const char* name)
{ {
char *query = nullptr; std::string query = StringFormat("SELECT id FROM character_ where name='%s'", name);
auto results = QueryDatabase(query);
auto results = QueryDatabase(query, MakeAnyLenString(&query, "SELECT id FROM character_ where name='%s'", name));
if (!results.Success()) if (!results.Success())
{ {
std::cerr << "Error in CheckUsedName query '" << query << "' " << results.ErrorMessage() << std::endl; std::cerr << "Error in CheckUsedName query '" << query << "' " << results.ErrorMessage() << std::endl;
safe_delete_array(query);
return false; return false;
} }
safe_delete_array(query);
if (results.RowCount() > 0) if (results.RowCount() > 0)
return false; return false;