2023-05-24, 09:20 PM
I need a code to find the name and check its existence in the database, but I don't know what is the best code for this task so that it works at the highest possible speed and is optimal.
Sorry for my bad english ;)
Witch one is better?
Or
Sorry for my bad english ;)
Witch one is better?
Code:
Std::MySQLCheckAccount(const name[]) {
new Query[128];
format(Query, sizeof(Query), "SELECT 1 FROM `users` WHERE `username`='%s' LIMIT 1", name);
mysql_tquery(gMySQL, Query, "OnMySQLCheckAccount");
return true;
}
Void::OnMySQLCheckAccount() {
switch cache_num_rows() do {
case false: return print("Not find");
default: return print("Find");
}
}
Or
Code:
Std::MySQLCheckAccount2(const name[]) {
inline const checkAccount() {
switch cache_num_rows() do {
case false: return print("Not find");
default: return print("Find");
}
}
MySQL_PQueryInline(gMySQL, using inline checkAccount, "SELECT `username` FROM `users` WHERE `username` = '%s' LIMIT 1", name);
return true;
}