Best way to save Server Settings [MySQL]
#1

Hi,

I need to save server settings in MySQL but i don't have idea how to do it.

I have something like this:

Код:
enum Server
{
isRegister,
isAds,
isAsk
isReport
isHappyHours
};
new ServerInfo[Server];
So how to save it?I just have idea with many fields and one row..I don't know is it good.

This:




I think that i need to do it with more rows but i don't have idea how to load/save it on it way..
Reply
#2

I would go with two columns multi rows,
Example:
settings table has:

Setting column as string
Value column as integer or w/e

Now you just insert rows:
isRegister value 0/1
isAds value 0/1
..etc
Reply
#3

Quote:

Setting column as string
Value column as integer or w/e

I understand it.But how to load it in enum?
I know just on this way with strcmp,but i think it's not good

Код:
mysql_tquery(g_SQL,SELECT * FROM `settings`","LoadSettings");
Код:
forward LoadSettings();
public LoadSettings()
{
	new rows = cache_num_rows();
	new setting[20],value;
	if(rows)
	{
		for(new i; i<rows; i++)
		{
			cache_get_value_name(i,"SettingName",setting);
			cache_get_value_int(i,"Value",value);
			if(strcmp(setting, "isAds") == 0)
			{
				ServerInfo[isAds] = value;
			}
			else if(strcmp(setting, "isReport") == 0)
			{
				ServerInfo[isReport] = value;
			}
			..
			...
		}
	}
	return 1;
}
Reply
#4

If the loading is in correct order, this might also work:
pawn Код:
ServerInfo[Server: i] = value;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)