title: Set Database Value As Config Item Codeigniter
body: <p>How am I able to get the <strong>key value</strong> and the set it as a <strong>config_item</strong>. I have been trying to be able to get so can do it via form and database. I can only seem to seem to change config Item manually.</p>
  
  <p>I have a form where It finds the themes and then saves the one I choose to the database. </p>
  
  <pre><code>Table Name Setting
  
  setting_id = 1
  
  group = config 
  
  key = config_template
  
  value = Name of theme submitted in form.
  </code></pre>
  
  <p>I would like to be able to some how use <code>$this-&gt;config-&gt;item('config_template')</code> so it will get the value.</p>
  
  <p><strong>Because I am trying to achieve this front controller</strong> </p>
  
  <pre><code> &lt;?php
        class Home extends CI_Controller {
          public function index() {
            if(file_exists(DIR_TEMPLATE . $this-&gt;config-&gt;item('config_template') . '/template/common/home.php')) {
               $this-&gt;load-&gt;view($this-&gt;config-&gt;item('config_template') . '/template/common/home');
            } else {
               $this-&gt;load-&gt;view('default/template/common/home');
            }
          }
        }
  </code></pre>
  
  <p><strong>Backend Setting Controller</strong> </p>
  
  <pre><code>&lt;?php
  
  class Setting extends CI_Controller {
  
      public function index() {
  
          $this-&gt;load-&gt;model('setting_model');
  
          if ($this-&gt;input-&gt;server('REQUEST_METHOD') == 'POST') {
              $this-&gt;setting_model-&gt;editSetting('config', $this-&gt;input-&gt;post());
              redirect('store');
          }
  
          $data['action'] = site_url('setting');
  
          if (null !==($this-&gt;input-&gt;post('config_template'))) {
              $data['config_template'] = $this-&gt;input-&gt;post('config_template');
          } else {
              $data['config_template'] = $this-&gt;config-&gt;item('config_template');
          }
  
          $data['templates'] = array();
  
          $directories = glob(DIR_APPLICATION . 'views/theme/*', GLOB_ONLYDIR);
  
          foreach ($directories as $directory) {
              $data['templates'][] = basename($directory);
          }
          return $this-&gt;load-&gt;view('setting/setting', $data);
      }
   }
  </code></pre>