Closed th3-sh0w3r closed 5 years ago
It parses ' and " quotes, like Arma does too. ` is not a valid quote
But I have another array, and there are these characters around numbers and that works. Maybe it only works on numbers. I think I will use some other characters now. Thanks.
Edit: Can you tell me why it doesn‘t turn „[30,30]“ into [30,30]?
„
and “
are not valid quotes. Only "
and '
Yes I mean these 2 but i‘m on the phone and can‘t write that characters. But the command doesn‘t remove them.
@dedmen Now I'm at the PC and I mean "[30,30]" into [30,30]
Wait...
What are you actually storing in the database?
Are you storing the string [30,30]
like
SELECT "[30,30]"
or are you storing
"[30,30]"
like SELECT "\"[30,30]\""
?
The parsing code is here: https://github.com/intercept/intercept-database/blob/master/src/res.cpp#L92 I don't take care of any quotes, everything is done by parseSimpleArray command. If it doesn't work with parseSimpleArray then I don't think I can help you much. Can you maybe attach a SQL dump file so I can see what data you actually have? Maybe just a small excerpt of your db.
Wait... What are you actually storing in the database? Are you storing the string
[30,30]
likeSELECT "[30,30]"
or are you storing"[30,30]"
likeSELECT "\"[30,30]\""
?The parsing code is here: https://github.com/intercept/intercept-database/blob/master/src/res.cpp#L92 I don't take care of any quotes, everything is done by parseSimpleArray command. If it doesn't work with parseSimpleArray then I don't think I can help you much. Can you maybe attach a SQL dump file so I can see what data you actually have? Maybe just a small excerpt of your db.
I'm storing "[30,30]"
not "\"[30,30]\""
This is my table:
DROP TABLE IF EXISTS
players`;
CREATE TABLE players
(
uid
int(12) NOT NULL AUTO_INCREMENT,
name
varchar(32) NOT NULL,
aliases
text NOT NULL,
playerid
varchar(50) NOT NULL,
cash
varchar(400) NOT NULL DEFAULT '"[0,0,0,0]"',
bankacc
varchar(400) NOT NULL DEFAULT '"[0,0,0,0]"',
coplevel
enum('0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20') NOT NULL DEFAULT '0',
mediclevel
enum('0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20') NOT NULL DEFAULT '0',
opforlevel
enum('0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20') NOT NULL DEFAULT '0',
civ_licenses
text NOT NULL,
cop_licenses
text NOT NULL,
med_licenses
text NOT NULL,
opfor_licenses
text NOT NULL,
civ_gear
text NOT NULL,
cop_gear
text NOT NULL,
med_gear
text NOT NULL,
opfor_gear
text NOT NULL,
civ_stats
varchar(400) NOT NULL DEFAULT '"[100,100,100,0]"',
cop_stats
varchar(400) NOT NULL DEFAULT '"[100,100,100,0]"',
med_stats
varchar(400) NOT NULL DEFAULT '"[100,100,100,0]"',
opfor_stats
varchar(400) NOT NULL DEFAULT '"[100,100,100,0]"',
arrested
int(12) NOT NULL,
adminlevel
enum('0','1','2','3','4','5') NOT NULL DEFAULT '0',
civ_alive
tinyint(1) NOT NULL DEFAULT '0',
civ_position
varchar(64) NOT NULL DEFAULT '"[]"',
skill_level
varchar(400) NOT NULL DEFAULT '"[0,0]"',
pin
int(4) NOT NULL DEFAULT '0',
blueprints
text NOT NULL,
insert_time
timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
last_seen
timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (uid
),
UNIQUE KEY playerid
(playerid
),
KEY name
(name
)
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=latin1;
`
The command only selects type of varchar. The other arrays in text, longtext are not shown/selected. But it doesn't remove the quotes from the array. It is just like the normal dbResultToArray but only with removing of text, longtext etc.
And another question, this is my config.yalm
insertRequestInsert: > INSERT INTO players (playerid, name, cash, bankacc, aliases, arrested, skill_level, cop_licenses, med_licenses, civ_licenses, opfor_licenses, civ_gear, cop_gear, med_gear, opfor_gear, blueprints) VALUES(?, ?, ?, ?, ?, ?, ?, '"[]"', '"[]"', '"[]"', '"[]"', '"[]"', '"[]"', '"[]"', '"[]"', '"[]"')
Do I need to put the ' apostrophs around it?
I'm storing "[30,30]" not "\"[30,30]\""
No.. You're not.
'"[100,100,100,0]"' '"[]"' '"[0,0]"'
You are storing "[0,0]"
instead of what you're supposed to [0,0]
Your strings are not supposed to have embedded quotes.
That's your problem.
I'm storing "[30,30]" not ""[30,30]""
No.. You're not.
'"[100,100,100,0]"' '"[]"' '"[0,0]"'
You are storing
"[0,0]"
instead of what you're supposed to[0,0]
Your strings are not supposed to have embedded quotes. That's your problem.
Ohh wow... I thought mysql isn't working if I don't use the apostrophs. I will test it. Thank you.
That means in my config.yaml I must only use the ?
and then I can go and insert a array like this "[30,30]"
Because I tried that yesterday but it didn't work for me. Even that removed the array from the select. Or do I need to insert the array without quotes and it will select it with quotes?
@dedmen Maybe it removes the rows because in the file https://github.com/intercept/intercept-database/blob/bf27d7adf4c673d75d6d3b30454c88c36d974472/src/res.cpp#L61 you added blob support from this issue: https://github.com/intercept/intercept-database/issues/11 but not blob support for the parsedArray command: https://github.com/intercept/intercept-database/blob/bf27d7adf4c673d75d6d3b30454c88c36d974472/src/res.cpp#L85
Hey, @dedmen
i've added blob support to the parsed array command and now it works :) Thank you very much for your help. Maybe you can update/add this in the future.
This is what I changed: https://github.com/nflug/intercept-database/commit/2f5ead0f2a6e8fd5f356f8c1edaee69407446a80
you added blob support from this issue: #11 but not blob support for the parsedArray command
AH! I only tested that with varchar, not text.
That means in my config.yaml I must only use the ? and then I can go and insert a array like this "[30,30]"
Yes, but make sure that your string is actually "[30,30]" and not """[30,30]"""
deae4aee9a0959e9177c2fea2d45eb11919b94cc
Hey,
(replace # with `, can't do that because of github code insert)
my connection works fine now. But there is another problem. I have some arrays in my DB like: "[#license_civ_air#, 0]" and the gear array "[#U_C_Poloshirt_blue#,##,##,##,##,[#ItemMap#,#ItemCompass#,#Itemwatch#],##,##,##,[],[],[],[],[],[],[##,##,##,##],[##,##,##,##],[##,##,##,##],[],[],[],[]]".
This is my result if I use dbResultToArray
and this is my result if I use dbResultToParsedArray:
Instead of turning the array from "[#license_civ_air#, 0]" to [#license_civ_air#, 0] it just removes it.
What can I do there?
EDIT: The other arrays like ""[70,80,100,0]"" doesn't turn into [70,80,100,0] too.