Skip to content

Instantly share code, notes, and snippets.

@dead1ock
Created October 14, 2011 22:47
Show Gist options
  • Save dead1ock/1288583 to your computer and use it in GitHub Desktop.
Save dead1ock/1288583 to your computer and use it in GitHub Desktop.
bool MysqlAccountProvider::AutoRegisterAccount(std::string username, std::string password) {
bool success = false;
try {
string sql = "call sp_CreateAccount(?,?,?);";
auto conn = db_manager_->getConnection("galaxy_manager");
auto statement = shared_ptr<sql::PreparedStatement>(conn->prepareStatement(sql));
statement->setString(1, username);
statement->setString(2, password);
statement->setString(3, "");
auto rows_updated = statement->executeUpdate();
if (rows_updated > 0)
success = true;
} catch(sql::SQLException &e) {
DLOG(ERROR) << "SQLException at " << __FILE__ << " (" << __LINE__ << ": " << __FUNCTION__ << ")";
DLOG(ERROR) << "MySQL Error: (" << e.getErrorCode() << ": " << e.getSQLState() << ") " << e.what();
}
return success;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment