I have the code below that access my table called settings
in my database and then creates an array called data. Currently I have it MY_Controller but I want to move it to a library so I can access the settings from models etc. The only problem is every time I try I get an undefined index error.
public function _settings()
{
// select all settings from database
$query = $this->db->query('SELECT * FROM settings');
// get result from database
$this->data = $query->result_array();
foreach($this->data as $setting)
{
// create data variable from database variables
$this->data[$setting['name']] = $setting['value'];
}
// simplify access to urls
$this->data['base_url'] = base_url();
$this->data['site_url'] = site_url();
$this->data['template_url'] = base_url('assets/templates/' . $this->data['template']);
// return array of data
return $this->data;
}
Please help...