Mysql "SELECT *" - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Mysql "SELECT *" (
/showthread.php?tid=253017)
Mysql "SELECT *" -
iggy1 - 04.05.2011
I have only just started using Mysql in my code i have a small IsPlayerRegistered function and i use "SELECT *" just to see if any
columns are returned (thanks ******
). Is that much more inefficient than just selecting one column? I know i could use either, but i would still like to know which is best to use in this situation.
pawn Код:
stock IsPlayerRegistered(playerid)
{
new
query[DEFAULT_QUERY_SIZE], eName[MAX_PLAYER_NAME];
mysql_real_escape_string(gPlayerData[playerid][e_zPlayerName], eName);
format(query, sizeof(query), "SELECT * FROM `users` WHERE `username` = '%s'", gPlayerData[playerid][e_zPlayerName]);//should i select all or one row here?
mysql_query(query);
mysql_store_result();
if(mysql_num_rows() != 0)
{
mysql_free_result();
return 1;
}
else
{
mysql_free_result();
return 0;
}
}
Thanks for your time.
Re: Mysql "SELECT *" -
Hiddos - 04.05.2011
I'd just select the row, but I'm no good at MySQL. I wouldn't post here anyways, but what's the 'eName' string meant for if you're not using it?
Re: Mysql "SELECT *" -
iggy1 - 04.05.2011
I use it to escape the players name (sql inject)
pawn Код:
mysql_real_escape_string(gPlayerData[playerid][e_zPlayerName], eName);
EDIT: LMAO i just noticed it wasn't used in the query thanks for spotting that.
Re: Mysql "SELECT *" -
Retardedwolf - 04.05.2011
Hm, I have seen ****** once use SELECT null, maybe try that.
Re: Mysql "SELECT *" -
iggy1 - 04.05.2011
Hmm i'm not sure what you mean. Like this?
pawn Код:
format(query, sizeof(query), "SELECT null FROM...
If so ill give it a try because i could use a much smaller query size.
Re: Mysql "SELECT *" -
Retardedwolf - 04.05.2011
Yeah
Re: Mysql "SELECT *" -
iggy1 - 04.05.2011
Works like a charm nice1.