/// Fetches the next account in the database. static bool account_db_sql_iter_next(AccountDBIterator* self, struct mmo_account* acc) { AccountDBIterator_SQL* iter = (AccountDBIterator_SQL*)self; AccountDB_SQL* db; Sql* sql_handle; char* data; nullpo_ret(iter); db = (AccountDB_SQL*)iter->db; nullpo_ret(db); sql_handle = db->accounts; // get next account ID if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `account_id` FROM `%s` WHERE `account_id` > '%d' ORDER BY `account_id` ASC LIMIT 1", db->account_db, iter->last_account_id) ) { Sql_ShowDebug(sql_handle); return false; } if( SQL_SUCCESS == SQL->NextRow(sql_handle) && SQL_SUCCESS == SQL->GetData(sql_handle, 0, &data, NULL) && data != NULL ) {// get account data int account_id; account_id = atoi(data); if( mmo_auth_fromsql(db, acc, account_id) ) { iter->last_account_id = account_id; SQL->FreeResult(sql_handle); return true; } } SQL->FreeResult(sql_handle); return false; }
/// retrieve data from db and store it in the provided data structure static bool account_db_sql_load_num(AccountDB* self, struct mmo_account* acc, const int account_id) { AccountDB_SQL* db = (AccountDB_SQL*)self; return mmo_auth_fromsql(db, acc, account_id); }