I have the following model that print_r
shows Array ( [id] => 1 [cms_name] => Content Mangement System )
Currently in my controller I have $data['contentMangement'] = $this->model->function
but I am unsure how to bring my above array into this.
function systemOptions($options)
{
$this->db->select($options);
$query = $this->db->get('options');
if($query->num_rows() > 0)
{
$row = $query->row_array();
$row['cms_name'];
}
print_r($row);
return $query->result_array();
}
If you want all of your options you can do this:
function systemOptions($options)
{
$this->db->select($options);
return $this->db->get('options')->result_array();// will return empty array if there are no results
}
Or if you just want the first row (which is what it looks like from your question) you can do this:
function systemOptions($options)
{
$this->db->select($options);
$result = $this->db->get('options')->result_array();
if(!empty($result))
{
return $result[0];
}else{
return null; //or false or array(), or whatever you want
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.