This extension allows you to store special config entries needed by your application into a database.
... 'components' => array( ... 'config' => array( 'class' => 'application.extensions.EConfig', ), ... ), ...
In order to use this extension, you have to make sure a database component is configured in your config. Also for better performance a configured cache component is a good idea.
These properties are available and can be set in the config:
configTableNameDefaults to "Config". This is the name of the database table used to store the config entries.
autoCreateConfigTableDefaults to true. Wether the database table should be auto-created. For performance reasons you should turn this off once the table got created.
connectionIDDefaults to "db". The ID of the database component.
cacheIDDefaults to false. The ID of the cache component. If set to false, no caching will be performed.
strictModeAvailable since version 1.1. Defaults to true. If this is set to false, you can get/set entries even if the entry is not yet present in the database.
By default the created database table is empty. That means you can't get or set any config entry. In order to make it work, you have to add every needed config entry to the database (for example with PHPMyAdmin). Since the extension stores values serialized, you have to make sure you add the needed entries with
NULL as value. After that you can safely get or set your entries.
Since version 1.1 you can set the new
strictMode property to false in order to get or set a value even if the entry is not present in the database. That works as follows: If you try to get an entry which is not present, NULL is returned. If you try to set an entry which is not present, the entry will be auto-inserted into the database. Please note that if you have a typo in your $key value when getting an entry, NULL is returned instead of a thrown exception. I suggest to just leave strict mode enabled.
To get an entry:
$var = Yii::app()->config->get($key);
To set an entry:
Since values are stored serialized, it's no problem to work with booleans or arrays.