Overwritting config by DB
Brought to you by:
olafvdspek
server.cpp, function Cserver::read_config(), file config must reads before DB, was:
Csql_result result = Csql_query(m_database, "select name, value from @config where value is not null").execute();
for (Csql_row row; row = result.fetch_row();) {
if (config.set(row[0].s(), row[1].s()))
std::cerr << "unknown config name: " << row[0].s() << std::endl;
}
Cconfig config;
config.load(m_conf_file);
now:
Cconfig config;
config.load(m_conf_file);
Csql_result result = Csql_query(m_database, "select name, value from @config where value is not null").execute();
for (Csql_row row; row = result.fetch_row();) {
if (config.set(row[0].s(), row[1].s()))
std::cerr << "unknown config name: " << row[0].s() << std::endl;
}
Why?
I think that main config in file and in DB we can overwrite some vars in mysql table.
Sorry, im russian.
Bad that there i can't edit comments. Actually, I think that in the config file contains the initial values of variables, but now using the database, we can rewrite them, because it's easier than edit the file.
(c) Translated by Google
It's the other way around. The conf file overrides the config table.