AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   DB query explode (https://forums.alliedmods.net/showthread.php?t=155208)

Clauu 04-18-2011 15:44

DB query explode
 
Hi there,
I have a mysql table called "names" that contains the value "name1,name2,name3" .. how can i extract every single string and insert it into a variable? like var1 = name1, var2 = name2 and var3 = name3 ?

Exolent[jNr] 04-18-2011 21:27

Re: DB query explode
 
Code:
stock str_explode(const string[], delimiter, output[][], output_size, output_len) {     new i, pos, len = strlen(string);         do     {         pos += (copyc(output[i], output_len, string[pos], delimiter) + 1);     }     while(pos < len && ++i < output_size);         return i; }

Code:
new names[128]; // value from database new name[3][32]; // 3 = max number of values to split, 32 = max length of value str_explode(names, ',', name, sizeof(name), charsmax(name[])); // name[0] = "name1" // name[1] = "name2" // name[2] = "name3"

Clauu 04-19-2011 00:05

Re: DB query explode
 
Wow, thanks a lot man :up: And also it is possible to protect some data against decompiling softwares? like my connection details for the db? I have tried to decompile it with the wraith_disassembler and all of my db connection details where there visibile .. btw i have also decompiled an another plugin that is using a db and surprise there where no db connection details to see so seems that is possible to protect some db details but how?


All times are GMT -4. The time now is 19:50.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.