CodeIgniter: Passing information from the Model to the Controller using result_array()

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();
    }

Answers


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
    }
}

Need Your Help

What is the best practice for designing android UI?

java android android-layout android-xml

I am developing an enterprise application in android which has more than 50 screens, so i must look deep into memory management. I am confused about designing it's user iterface in xml or by code. ...

Hippo CMS resets the mapped domain configuration data after rebuild

maven content-management-system hippocms domain-mapping

I have installed an instance of Hippo CMS (version 7) and I already mapped a domain to a website. I also have an external repository for Hippo.