Safety of globalizing config data I have some framework in PHP/MySQL for developing web services. Finally my code works on two servers - production and developer. My idea is to create one code without differences, which will work different on both servers, depend of config. I created table [ini], with two rows of data, where I can specifically change settings of many parameters like:


email address of administrator, which is used to inform him about registration new user,
IDs of advertising banners to display on some pages,
page name to redirect after successful logging,
ID of default role of new user
etc.


I can of course prepare a class for read one specify setting when it is necessary, but it means that I will read data from my [ini] table dozen times in many PHP files.

Is it safe to read it once and globalize by following code?

//on developer machine my INI_ID == 0, on production server INI_ID == 1
if($_SERVER['SERVER_NAME'] == 'www.developer_domain_name.com'){
 define('INI_ID',0); 
}
else{
 define('INI_ID',1);
}

$row = function_SQLToRow('SELECT * FROM ini WHERE ini_id = ' . INI_ID . '');
$GLOBALS['ini'] = $row;


I'm open for other solutions, maybe storing config in file and read specific file depend on server, or prepare list of constants depend on server are safer solutions?
Yes, it is safe. No, it is not a good idea.

Don't mix application logic and configuration with the database, the database is used for permanent storage of data.

Use a file (json, ini, xml, whatever) which is named the same but has different contents in production/dev environments. Then, it's as simple as:

$config = json_decode(file_get_contents('config.json')); //I'm assuming JSON here


Also, please don't globalize configuration. Pass whichever config option you need (just that config option, not the whole configuration array) into whatever function/object that needs it.