0
我有下面的代碼訪問我的表在我的數據庫中稱爲settings
,然後創建一個名爲數據的數組。目前我有它MY_Controller,但我想將它移動到一個庫,所以我可以從模型等訪問設置。唯一的問題是每次我嘗試我得到一個未定義的索引錯誤。如何將此代碼放入codeigniter的庫中?
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;
}
請幫助...
請寫出錯誤 – safarov 2012-04-11 05:38:51
我不再只是接收到錯誤空白頁... – swenflea 2012-04-11 05:48:29