SA-MP Forums Archive
Shortening a MySQL 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: Shortening a MySQL Query? (/showthread.php?tid=657037)



Shortening a MySQL Query? - Jing_Chan - 30.07.2018

So this is my query, as it's so long it prevents players from registering.

pawn Код:
new DB_Query[5000];

mysql_format(Database, DB_Query, sizeof(DB_Query), "INSERT INTO `PLAYERS` (`USERNAME`, `PASSWORD`, `SALT`, `REGDATE`, `SCORE`, `KILLS`, `CASH`, `DEATHS`, `ADMIN`, `SKIN`, `TOKENS`, `DONATOR`, `NAMECHANGES`, `TOKENS`, `HEADSHOTS`)\
                VALUES ('%e', '%s', '%e', NOW(), '0', '0', '0', '0', '0', '29', '0', '0', '0', '0', '0')"
, pInfo[playerid][Name], pInfo[playerid][Password], pInfo[playerid][Salt]);
                mysql_pquery(Database, DB_Query, "OnPlayerRegister", "d", playerid);
Is there a way I can shorten it or divide it into two separate queries to make it work?


Re: Shortening a MySQL Query? - Rufio - 30.07.2018

Why do you need a 5000 size array for this query? I use different functions to save my data like this;

UpdatePlayerCharacter(playerid);
UpdatePlayerAccountData(playerid);
UpdatePlayerRadioGPSSettings(playerid);
UpdatePlayerKillsAndDeaths(playerid);
UpdatePlayerFurniture(playerid);

This may or may not work for you, it can cause MASSIVE data heaps for your server to handle. I've tried multiple methods and this worked best for me, it's kinda a trial-error result. Your saving function is certainly shorter than mine though so it should work.


Re: Shortening a MySQL Query? - Jing_Chan - 30.07.2018

Quote:
Originally Posted by Rufio
Посмотреть сообщение
Why do you need a 5000 size array for this query? I use different functions to save my data like this;

UpdatePlayerCharacter(playerid);
UpdatePlayerAccountData(playerid);
UpdatePlayerRadioGPSSettings(playerid);
UpdatePlayerKillsAndDeaths(playerid);
UpdatePlayerFurniture(playerid);

This may or may not work for you, it can cause MASSIVE data heaps for your server to handle. I've tried multiple methods and this worked best for me, it's kinda a trial-error result. Your saving function is certainly shorter than mine though so it should work.
I was just putting the size up to see if it'd work. I can't register to the server for some reason with that query?


Re: Shortening a MySQL Query? - Calisthenics - 30.07.2018

Set default values in the table structure not in the query. The result will be:
pawn Код:
"INSERT INTO `PLAYERS` (`USERNAME`, `PASSWORD`, `SALT`, `REGDATE`) VALUES ('%e', '%s', '%e', NOW())"
As for your problem, check mysql logs.


Re: Shortening a MySQL Query? - Rufio - 30.07.2018

Quote:
Originally Posted by Jing_Chan
Посмотреть сообщение
I was just putting the size up to see if it'd work. I can't register to the server for some reason with that query?
Like Calisthenics mentioned you should check your MySQL log, it'll give you enough information to help you debug your query.


Re: Shortening a MySQL Query? - Jing_Chan - 30.07.2018

Quote:
Originally Posted by Rufio
Посмотреть сообщение
Like Calisthenics mentioned you should check your MySQL log, it'll give you enough information to help you debug your query.
There's literally nothing in the MySQL log..

edit: ignore me a sec, done MySQL_LOG(ALL)

https://pastebin.com/80Z1jnrH

any idea


Re: Shortening a MySQL Query? - Rufio - 30.07.2018

It might just be me not paying enough attention to the logs but it looks like you haven't tried to make server send INSERT INTO function, try to join the server with a brand new account and register, it'll send the registration query which you're having trouble with(i believe)