Shorten MYSQL Query
#1

Hi everyone,

Does anyone knows how to short this mysql query?
I have been trying a few things but i keep getting the input line too long error..
here is my query:
pawn Код:
new query[1024];
    format(query, sizeof(query), "UPDATE Users SET \
    Money = '%d', \
    Level = '%d', \
    Admin = '%d', \
    Helper = '%d', \
    VipLevel = '%d', \
    Skin = '%d', \
    Kills = '%d', \
    Deaths = '%d', \
    Muted = '%d', \
    Cell = '%d', \
    Cigs = '%d', \
    Watch = '%d', \
    Mask = '%d', \
    GasCan = '%d', \
    Sprunk = '%d', \
    Stereo = '%d', \
    GoldCoins = '%d', \
    PaymentMethod = '%d', \
    DriversLic = '%d', \
    WeaponLic = '%d', \
    HeavyVLic = '%d', \
    PilotLic = '%d', \
    BlockedPM = '%d',\
    Proposing = '%d',\
    Warnings = '%d',\
    MarriedTo = '%s',\
    Age = '%d',\
    PNumber = '%d',\
    PDesc = '%s',\
    PMail = '%s',\
    PCountry = '%s',\
    PSex = '%d',\
    PMailConfirmed = '%d'\
    WHERE Username = '%s'"
,
    GetPlayerMoney(playerid),
    GetPVarInt(playerid,"Score"),
    GetPVarInt(playerid,"Level"),
    GetPVarInt(playerid,"Helper"),
    GetPVarInt(playerid,"Vip Level"),
    GetPVarInt(playerid,"Skin"),
    GetPVarInt(playerid,"Kills"),
    GetPVarInt(playerid,"Deaths"),
    GetPVarInt(playerid,"Muted"),
    GetPVarInt(playerid,"HasCellphone"),
    GetPVarInt(playerid,"HasCigs"),
    GetPVarInt(playerid,"HasWatch"),
    GetPVarInt(playerid,"HasMask"),
    GetPVarInt(playerid,"GasCan"),
    GetPVarInt(playerid,"HasSprunk"),
    GetPVarInt(playerid,"HasStereo"),
    GetPVarInt(playerid,"GoldCoins"),
    GetPVarInt(playerid,"PMethod"),
    GetPVarInt(playerid,"DriversLic"),
    GetPVarInt(playerid,"WeaponLic"),
    GetPVarInt(playerid,"HeavyVLic"),
    GetPVarInt(playerid,"PilotLic"),
    PInfo[playerid][BlockedPM],
    PInfo[playerid][Proposing],
    PInfo[playerid][Warnings],
    PInfo[playerid][MarriedTo],
    PInfo[playerid][Age],
    PInfo[playerid][PNumber],
    PInfo[playerid][PDesc],
    PInfo[playerid][PMail],
    PInfo[playerid][PCountry],
    PInfo[playerid][PSex],
    PInfo[playerid][PMailConfirmed],
    GetPlayerNameEx(playerid));
    mysql_query(query);
I hope someone can help me
Thanks in advance
Reply
#2

Just spilt up into more queries literally. It doesn't matter how many queries you run as long as they are in the correct order.
Reply
#3

okay, thanks for the advice, i will try
Reply
#4

Use
pawn Код:
format(var, sizeof(var), "hi hi hi");
format(var, sizeof(var), "%s hi hi hi", var);
printf("%s", var); //prints out hi hi hi hi hi hi
Reply
#5

@jamesb93 Im sure running more queries has its disadvantages
I wouldn't say it the way you did, because it sounds like 1 or 1000 queries would be the same.
and i know they wouldn't. One trip to a database is kinda what ya go for, sometimes you may have to make another trip to the db but not normally.

I think you can get it all to fit in one query by using multiply format statements.
Reply
#6

Quote:
Originally Posted by Jonny5
Посмотреть сообщение
@jamesb93 Im sure running more queries has its disadvantages
I wouldn't say it the way you did, because it sounds like 1 or 1000 queries would be the same.
and i know they wouldn't. One trip to a database is kinda what ya go for, sometimes you may have to make another trip to the db but not normally.

I think you can get it all to fit in one query by using multiply format statements.
Please feel free to show me that running 2 instead of 1 dramatically slows down the server.

On-topic: I did pharse it wrongly, I was implying to format it on multiple times.
Reply
#7

Quote:
Originally Posted by jamesb93
Посмотреть сообщение
Please feel free to show me that running 2 instead of 1 dramatically slows down the server.

On-topic: I did pharse it wrongly, I was implying to format it on multiple times.
I never said Dramatically,
but just think of it this way, what is faster

1 call to function HI
or 2 calls to the same function HI.

but you meant split the string into multi format statements,
not multi querys so i think that clears it up,


regards.
Reply
#8

So, I should do it like Buughost said?
Just multiple formats?

Thanks for all the help everyone
Reply
#9

Just make big lines, but delete small bits off - get the maximum for one format, and query. Then, format again and another query.

It takes no time at all.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)