/ Published in: PHP
URL: http://codeigniter.com/forums/viewthread/103684/#674817
Credit: 'Jelmer' from CodeIgniter Forums
Create preferences.php in your application/config/ directory.
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.
Add 'preferences' to the config array of your application/config/autoload.php file.
Access the values using $this->config->item(); like you would with any other config value.
Celebrate with a beer.
Expand |
Embed | Plain Text
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); }
Comments
Subscribe to comments
You need to login to post a comment.

Hi fand die Idee gut und habe das mal ein bisschen erweitert.
CREATE TABLE IF NOT EXISTS
ge_preferences(idint(11) NOT NULL AUTOINCREMENT,modulvarchar(100) COLLATE utf8unicodeci NOT NULL,namevarchar(100) COLLATE utf8unicodeci NOT NULL,valuetext COLLATE utf8unicodeci NOT NULL,descriptiontext COLLATE utf8unicodeci NOT NULL,createddatetime NOT NULL DEFAULT '0000-00-00 00:00:00',last_updatedatetime NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8unicodeci AUTOINCREMENT=14 ;hmmm würde es ja gerne posten, nur scheint es hier nicht möglich zu sein. :)