Format VS MYSQL_FORMAT
#1

Hi !
I am not sure what to use format or mysql_format... Which is more faster ?
Reply
#2

mysql_format is for mysql databases,
And yes mysql will always be faster, I have experience with these things...
Reply
#3

I use it for creating a query...
Thanks . Can you argue?
Reply
#4

Quote:
Originally Posted by ******
View Post
Care to share this experience, maybe in the form of speed test comparisons?
It was about a year ago, And it was on my laptop which crashed and I lost all information... If I ever have the time I will try to check it again...But after I finish scripting a project for Battlezone...
Reply
#5

Format is good overall.
MySQL_format is usefull for creating queries for MySQL.

Format doesn't support %e, mysql_format does.
The %e is used for escaping strings to prevent mysql-injections.
It's basically identical to using mysql_real_escape_string.

The difference is that you first need to escape a string and store it in a variable, then insert the variable in a format, so you need 2 instructions to create escaped queries using format.
pawn Code:
new EscapedName[30], Query[128], Name[24];
GetPlayerName(playerid, Name, sizeof(Name));
mysql_real_escape_string(Name, EscapedName, ConnectionHandle);
format(Query, sizeof(Query), "INSERT INTO playerdata (PlayerName) VALUES ('%s')", EscapedName);
Using mysql_format and %e only requires 1 instruction so your code gets shorter and less complex.
pawn Code:
new Query[128], Name[24];
GetPlayerName(playerid, Name, sizeof(Name));
mysql_format(ConnectionHandle, Query, sizeof(Query), "INSERT INTO playerdata (PlayerName) VALUES ('%e')", Name);
As for speed, I haven't checked this yet.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)