Revision: 21082
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 2, 2009 21:01 by traeregan
Initial Code
function _export_preferences() { $this->load->helper('file'); $preferences = $this->db->get('preferences'); $preferences = $preferences->result(); $preferences_file = '<?php'."\n\n"; foreach ($preferences as $row) { $preferences_file .= '$config[\''.addslashes($row->name).'\'] = \''.addslashes($row->value).'\';'."\n"; } write_file(APPPATH.'config/preferences.php', $preferences_file); }
Initial URL
http://codeigniter.com/forums/viewthread/103684/#674817
Initial Description
Credit: 'Jelmer' from CodeIgniter Forums 1. Create preferences.php in your application/config/ directory. 2. Add this to the controller that writes your config values to the database so that it will also write them to the preferences.php config file. 3. Add 'preferences' to the config array of your application/config/autoload.php file. 4. Access the values using $this->config->item(); like you would with any other config value. 5. Celebrate with a beer.
Initial Title
CodeIgniter - Database Based Config
Initial Tags
codeigniter
Initial Language
PHP