Shortening a MySQL Query?
#1

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?
Reply
#2

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.
Reply
#3

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?
Reply
#4

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.
Reply
#5

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.
Reply
#6

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
Reply
#7

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)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)