02.05.2017, 20:14
Hello,
Is this idea good to check if a phone number exist already?
I don't want to check database everytime, so I made it with cache. I don't know if this code is good... And I want to ask if there is a function better than this one... I don't know if is a good idea to make a loop in another one and I don't want to make an infinite loop than can result in a server freeze.
Is this idea good to check if a phone number exist already?
Код:
new randphone = 0, number = 0, ok = 0, query[64]; format(query, sizeof(query), "SELECT Phone FROM players WHERE Phone > 0"); new Cache: numbers = mysql_query(SQL, query); do { ok = 1; randphone = 10000 + random(89999); if(cache_get_row_count() > 0) { for(new i, j = cache_get_row_count(); i != j; i++) { number = cache_get_field_content_int(i, "Phone"); if(number == randphone) { ok = 0; } } } } while(ok == 0); cache_delete(numbers);