SA-MP Forums Archive
Size of a query - 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)
+--- Thread: Size of a query (/showthread.php?tid=507345)



Size of a query - anou1 - 17.04.2014

Hi,

I wanted to know, how to determine the size of a query.
Is it like a string ?

For example for those queries:

"SELECT * FROM `maisons`" is the size 24 ?

"mysql_format(mysql, query, sizeof(query), "UPDATE `joueurs` SET `Bannis`=%d, `RaisonBan`='%s', `BannisPar`='%s' WHERE `ID`=%d", pInfo[id][Bannis], pInfo[id][RaisonBan], joueuremetteur, pInfo[id][ID]);"

Is the size 248 ?


Is there any tool that can calculate it automatically ?


Thank you !


Re: Size of a query - RajatPawar - 17.04.2014

Size of a string.. well, each index holds one, so that makes it the.. ermm.. size?

pawn Код:
new _st[3] = "aaa";
You don't need to calculate the size of every string to perfectly optimise it, because it's not the 80s, but you need to be sensible about it too - using 128 string size for a 24 char player name OR 512 for a 128 client message, is stupidity. For the query you mentioned, the first size that popped to my head, SAFELY, was 40.


Re: Size of a query - Conradus - 17.04.2014

Here you go, this tool calculates the string length for you.


Re: Size of a query - anou1 - 17.04.2014

Okay, thank you guys.
Gonna check this


Re: Size of a query - Vince - 17.04.2014

Quote:
Originally Posted by Conradus
Посмотреть сообщение
Here you go, this tool calculates the string length for you.
Except that it doesn't at all account for placeholders like %d and %s. The output as represented by that "tool" will - when used straight up as an array's size - produce a load of errors at runtime.


Re : Size of a query - S4t3K - 17.04.2014

Vince is right.

%s took 2 characters, whereas the string which is represented by the %s takes generally more than 2 characters.
My way to proceed is to create a 1024 chars string that I use for the queries, for sending mails, for sending client messages, for formatted gametexts...for whatever I want.