open.mp forum
[Pawn] I need a code to find the name and check its existence in the database. - Printable Version

+ open.mp forum (https://forum.open.mp)
-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
--- Thread: [Pawn] I need a code to find the name and check its existence in the database. (/showthread.php?tid=2394)



I need a code to find the name and check its existence in the database. - imnikolaidev - 2023-05-24

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?

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;
}