SA-MP Forums Archive
Counting query size - 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: Counting query size (/showthread.php?tid=617208)



Counting query size - vassilis - 17.09.2016

Hello guys, i have a typical easy question for MySQL. How much cells should i use for a query?

Example:
"SELECT * FROM `reports` WHERE `Name` = '%e'"
Result: 43(string size) + MAX_PLAYER_NAME around 50 cells for this query?
So my question is how to count query size? Should i count String size + MAX_PLAYER_NAME (if it is required) or something else?


Re: Counting query size - Shinja - 17.09.2016

SELECT * FROM `reports` WHERE `Name` = '%e' = 44 Characters, %e will be replaced by a name maximum size 24
so we will remove 2(%e) 44 - 2 = 42
42+24= 66
So 66 is the maximum size in this query


Re: Counting query size - Spmn - 17.09.2016

Don't forget the null character.


Re: Counting query size - vassilis - 17.09.2016

So query size depends on the string size generally?


Re: Counting query size - Gammix - 17.09.2016

EDIT: i got what you mean there.

So size is basically not a big deal when you have a rough idea how much cells it would take. Lets say i have these two queries and i know how much max they can go:

pawn Код:
new query[128];
"SELECT * FROM `users` WHERE `name` = '%q' AND `password` = '%q'"
pawn Код:
new query[512];
"INSERT INTO `users` (`name`, `password`, `data`, ...) VALUES ('%q', '%q', '%q', ...)"



Re: Counting query size - Konstantinos - 17.09.2016

Quote:
Originally Posted by vassilis
Посмотреть сообщение
So query size depends on the string size generally?
Yes, but you should count more characters in case some of them would be escaped. According to maddinat0r, it is 2 * <string to escape> + 1 for the worst case (every single character to be escaped).


Re: Counting query size - vassilis - 17.09.2016

Ok thank you all!