I'm using codeIgniter as my framework to build a very big website. Everything is fine. I use Models to get/send data from/to database. But a question has recently confused me. In getting data from loops throughout the page, I don't use the Models.
For instance, for the right sidebar I use a loop to get the list of categories. Now, this loop is based upon an array, and this array is a set of data retrieved from Database. This data-retrieval from DB is processed in the controller. Is this CORRECT? Or I should absolutely get any data from DB only and only in the MODELS? Since I only use Models for registrations/logins/newsletters/orders etc.
Here is one of my controller which also is responsible for getting DB data:
$this->niazer->
is a library which is responsible to get database data (solely made for my current project)
<?php
/**
This controller is the basic controller to render the webpages. Now we have the
**/
class show extends CI_Controller
{
function index()
{
/** getting list of categories **/
$cats = $this->niazer->get_pa('all'); // getting all the parents
$x= $this->niazer->get_child($cats);
$data['main_cats'] = $cats;
/** getting list of categories **/
/** getting list of special ads with 5-7 stars **/
$special_ads_var = $this->niazer->get_ads(array("star-min"=>5, "star-max"=>7, "row"=>5)); // getting all the parents
$data['special_ads'] = $special_ads_var;
/** end of special ads list **/
/** getting list of special ads with 5-7 stars **/
$special_ads_var = $this->niazer->get_news(array("limit"=>20)); // getting all the parents
$theme_name = $this->theme->get_theme_with_slash(false);
$this->load->view($theme_name.'header', $data);
$this->load->view($theme_name.'index', $data);
$this->load->view($theme_name.'footer', $data);
}
}